Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

intake_esm import test triggers some errors #24

Closed
rbeucher opened this issue Jul 7, 2023 · 8 comments
Closed

intake_esm import test triggers some errors #24

rbeucher opened this issue Jul 7, 2023 · 8 comments

Comments

@rbeucher
Copy link
Member

rbeucher commented Jul 7, 2023

Just came accross this today. I am skipping intake_esm in the tests because of it.

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/g/data/xp65/public/apps/med_conda/envs/access-med-0.2/lib/python3.10/site-packages/intake_esm/__init__.py:9: in <module>
    from .core import esm_datastore
/g/data/xp65/public/apps/med_conda/envs/access-med-0.2/lib/python3.10/site-packages/intake_esm/core.py:21: in <module>
    from .cat import ESMCatalogModel
/g/data/xp65/public/apps/med_conda/envs/access-med-0.2/lib/python3.10/site-packages/intake_esm/cat.py:68: in <module>
    class Assets(pydantic.BaseModel):
/g/data/xp65/public/apps/med_conda/envs/access-med-0.2/lib/python3.10/site-packages/intake_esm/cat.py:78: in Assets
    def _validate_data_format(cls, values):
/g/data/xp65/public/apps/med_conda/envs/access-med-0.2/lib/python3.10/site-packages/pydantic/deprecated/class_validators.py:222: in root_validator
    return root_validator()(*__args)  # type: ignore
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

pre = False, skip_on_failure = False, allow_reuse = False, __args = ()

    def root_validator(
        *__args,
        pre: bool = False,
        skip_on_failure: bool = False,
        allow_reuse: bool = False,
    ) -> Any:
        """Decorate methods on a model indicating that they should be used to validate (and perhaps
        modify) data either before or after standard model parsing/validation is performed.
    
        Args:
            pre (bool, optional): Whether this validator should be called before the standard
                validators (else after). Defaults to False.
            skip_on_failure (bool, optional): Whether to stop validation and return as soon as a
                failure is encountered. Defaults to False.
            allow_reuse (bool, optional): Whether to track and raise an error if another validator
                refers to the decorated function. Defaults to False.
    
        Returns:
            Any: A decorator that can be used to decorate a function to be used as a root_validator.
        """
        warn(
            'Pydantic V1 style `@root_validator` validators are deprecated.'
            ' You should migrate to Pydantic V2 style `@model_validator` validators,'
            ' see the migration guide for more details',
            DeprecationWarning,
            stacklevel=2,
        )
    
        if __args:
            # Ensure a nice error is raised if someone attempts to use the bare decorator
            return root_validator()(*__args)  # type: ignore
    
        if allow_reuse is True:  # pragma: no cover
            warn(_ALLOW_REUSE_WARNING_MESSAGE, DeprecationWarning)
        mode: Literal['before', 'after'] = 'before' if pre is True else 'after'
        if pre is False and skip_on_failure is not True:
>           raise PydanticUserError(
                'If you use `@root_validator` with pre=False (the default) you MUST specify `skip_on_failure=True`.'
                ' Note that `@root_validator` is deprecated and should be replaced with `@model_validator`.',
                code='root-validator-pre-skip',
            )
E           pydantic.errors.PydanticUserError: If you use `@root_validator` with pre=False (the default) you MUST specify `skip_on_failure=True`. Note that `@root_validator` is deprecated and should be replaced with `@model_validator`.
E           
E           For further information visit https://errors.pydantic.dev/2.0.2/u/root-validator-pre-skip

/g/data/xp65/public/apps/med_conda/envs/access-med-0.2/lib/python3.10/site-packages/pydantic/deprecated/class_validators.py:228: PydanticUserError
@rbeucher
Copy link
Member Author

rbeucher commented Jul 7, 2023

@dougiesquire any idea?

@dougiesquire
Copy link

Yup, I've actually just added a fix for this in Intake-ESM: intake/intake-esm#619

Until a new release of Intake-ESM is issued, the solution is to pin pydantic<2.0

@rbeucher
Copy link
Member Author

rbeucher commented Jul 7, 2023

Thanks @dougiesquire. Let's keep this one open until they fix it.

@dougiesquire
Copy link

dougiesquire commented Jul 7, 2023

I've fixed it, but the fix hasn't been released yet.

Intake-ESM (and hence the ACCESS-NRI catalog) won't work in any MED environment created before a new Intake-ESM version is released unless you pin pydantic<2.0.

@rbeucher
Copy link
Member Author

rbeucher commented Jul 7, 2023

Sure, I have done that.

@rbeucher
Copy link
Member Author

@dougiesquire should we put intake-esm back in the tests?

@dougiesquire
Copy link

Yes please

@rbeucher
Copy link
Member Author

Actually it is not there. I am closing then

rbeucher pushed a commit that referenced this issue Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants