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

[Bug]: Updates needed for pydantic v2 #161

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

[Bug]: Updates needed for pydantic v2 #161

dougiesquire opened this issue Jul 3, 2023 · 3 comments · Fixed by #164
Labels
bug Something isn't working

Comments

@dougiesquire
Copy link
Collaborator

What happened?

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

What did you expect to happen?

Able to use ecgtools with pydantic v2

Minimal Complete Verifiable Example

# With pydantic=v2.0
import ecgtools

Relevant log output

~/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/ecgtools/__init__.py", line 6, in <module>
    from .builder import Builder, RootDirectory, glob_to_regex
  File "~/miniconda3/envs/test/lib/python3.11/site-packages/ecgtools/builder.py", line 13, in <module>
    from intake_esm.cat import (
  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

Anything else we need to know?

This should be a pretty straightforward update. I'm happy to submit a PR if wanted.

@dcherian
Copy link
Contributor

dcherian commented Jul 3, 2023

Thanks for posting @dougiesquire . A PR would be great. Unfortunately ecgtools is mostly unmaintained at the moment.

I am going to give you maintainer privileges here :)

@dougiesquire
Copy link
Collaborator Author

Actually, I don't think there are any pydantic-related changes need in ecgtools. The issue comes because updates are needed in Intake-ESM, which ecgtools uses. I've opened an issue with Intake-ESM (see intake/intake-esm#617). Once that is resolved, I'll remove the pydantic version pins I added in #162 and close this issue.

@dougiesquire
Copy link
Collaborator Author

Actually (again), my previous post is not correct. There are a few changes needed. I'll make a PR now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants