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

Updates needed for pydantic v2 #617

Closed
dougiesquire opened this issue Jul 3, 2023 · 0 comments · Fixed by #619
Closed

Updates needed for pydantic v2 #617

dougiesquire opened this issue Jul 3, 2023 · 0 comments · Fixed by #619

Comments

@dougiesquire
Copy link
Contributor

Description

Pydantic v2 was released on July 1. Intake-ESM uses pydantic, but does not work with pydantic v2. Simply importing Intake-ESM with pydantic=v2.0 results in an error.

A few syntactical updated throughout Intake-ESM should resolve this issue.

What I Did

# With pydantic=v2.0
import intake_esm

gives

~/miniconda3/envs/test/lib/python3.11/site-packages/pydantic/_internal/_config.py:257: UserWarning: Valid config keys have changed in V2:
* 'validate_all' has been renamed to 'validate_default'
  warnings.warn(message, UserWarning)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "~/miniconda3/envs/test/lib/python3.11/site-packages/intake_esm/__init__.py", line 9, in <module>
    from .core import esm_datastore
  File "~/miniconda3/envs/test/lib/python3.11/site-packages/intake_esm/core.py", line 21, in <module>
    from .cat import ESMCatalogModel
  File "~/miniconda3/envs/test/lib/python3.11/site-packages/intake_esm/cat.py", line 68, in <module>
    class Assets(pydantic.BaseModel):
  File "~/miniconda3/envs/test/lib/python3.11/site-packages/intake_esm/cat.py", line 77, in Assets
    @pydantic.root_validator
     ^^^^^^^^^^^^^^^^^^^^^^^
  File "~/miniconda3/envs/test/lib/python3.11/site-packages/pydantic/deprecated/class_validators.py", line 222, in root_validator
    return root_validator()(*__args)  # type: ignore
           ^^^^^^^^^^^^^^^^
  File "~/miniconda3/envs/test/lib/python3.11/site-packages/pydantic/deprecated/class_validators.py", line 228, in root_validator
    raise PydanticUserError(
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`.

For further information visit https://errors.pydantic.dev/2.0/u/root-validator-pre-skip
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

Successfully merging a pull request may close this issue.

1 participant