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

support pydantic v2 #413

Merged
merged 1 commit into from Sep 15, 2023
Merged

support pydantic v2 #413

merged 1 commit into from Sep 15, 2023

Conversation

skshetry
Copy link
Member

@skshetry skshetry commented Sep 14, 2023

Also supports pydantic v1.

pydantic v2 provides v1 api through pydantic.v1 import, so we can support both versions by trying to import from pydantic.v1 and fallback to old behaviour.

See https://docs.pydantic.dev/latest/migration/#continue-using-pydantic-v1-features.

pydantic == 2.0.0 does not work due to pydantic/pydantic#6361, so we need to blacklist that specific version.

Also supports pydantic v1.

pydantic v2 provides v1 api through `pydantic.v1` import, so we can support
both versions by trying to import from `pydantic.v1` and fallback to old behaviour.

See
https://docs.pydantic.dev/latest/migration/#continue-using-pydantic-v1-features.

pydantic == 2.0.0 does not work due to pydantic/pydantic#6361,
so we need to blacklist that specific version.
@@ -41,11 +41,13 @@ class Config:

def assert_type(self, name):
assert_name_is_valid(name)
# pylint: disable-next=unsupported-membership-test
Copy link
Member Author

@skshetry skshetry Sep 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and the following is needed due to a false-positive with pylint. It's looking at above = None default value and raising a false-positive.

@shcheklein
Copy link
Member

@skshetry is there a reason to support both?

@skshetry
Copy link
Member Author

@skshetry is there a reason to support both?

Studio still relies on MLEM and therefore on Pydantic v1. Also I did not want to block any DVC users that are using pydantic v2 (or, pydantic v1 even).

Also, using pydantic v2 APIs means changing code, whereas if we use v1 APIs for now, we can support both and is working perfectly fine.

@shcheklein
Copy link
Member

sounds good. can we run tests with both then?

@skshetry
Copy link
Member Author

I consider pydantic v1 support as best effort from now on. I don’t think we need to test both.

@shcheklein
Copy link
Member

sound good, I think Studio has enough tests to detect failure if there is a regression in pydantic v1

@skshetry skshetry merged commit 463d8a3 into main Sep 15, 2023
17 checks passed
@skshetry skshetry deleted the pydantic-v2 branch September 15, 2023 05:23
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 this pull request may close these issues.

None yet

3 participants