-
Notifications
You must be signed in to change notification settings - Fork 12
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
IR: Update to Pydantic >2.0 compatibility #349
Conversation
Documentation for this branch can be viewed at https://sites.ecmwf.int/docs/loki/349/index.html |
c2ff8e1
to
fe4656f
Compare
fe4656f
to
8e134e1
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #349 +/- ##
==========================================
+ Coverage 95.29% 95.30% +0.01%
==========================================
Files 170 171 +1
Lines 36414 36490 +76
==========================================
+ Hits 34701 34778 +77
+ Misses 1713 1712 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
The `validate_assignments` config options was negating the "frozenness" of the dataclasses in the newer pydantic releases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great, many thanks for grinding this through!
Note:` For now, just for testing...This PR brings a few enabling changes to the internal IR node definitions that allow us to lift the version restriction on
pydantic
. We needed this previously, as we were relying on some (broken) default behaviour that was fixed upstream in pydantic version 2. By changing to the correct type annotations, in particular forOptional
arguments, we can now lift this restriction.In addition, I also added a small set of rudimentary checks for the constructor and object behaviour (immutability) for three most common/interesting node types. I plan to expand on this somewhat in a follow-up PR that will require pydantic features from version 2.x.
In some more detail:
Optional
throughout node type annotations to allow default values ofNone
Assignment
,Loop
andConditional
Note: This is the first of two PRs and paves the way for more cool stuff to come (as discussed offline).