-
Notifications
You must be signed in to change notification settings - Fork 21
Use Pydantic v2 at runtime #584
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
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 🚀 New features to boost your workflow:
|
3bcbc50 to
65870c5
Compare
| ) | ||
|
|
||
| @root_validator | ||
| @model_validator(mode="before") |
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.
FYI, this breaks filtering using the CurationWorkflow as seen in https://github.com/openforcefield/openff-sage/blob/a6a061ba8ebc144e3fda46f5f7a9e7a352b9cd2f/data-set-curation/physical-property/optimizations/curate-training-set.py#L103-L173 . Any reason it was set to "before"? "after" works for me.
I think it's because validation is run before the -- I wind up with errors like the below:type attribute (Literal) gets a chance to distinguish different classes
(Ignore the speculation above, I'm tired and not thinking clearly.)
2025-07-31 16:45:18,828 - __main__ - INFO - Starting at Thu Jul 31 16:45:18 2025
2025-07-31 16:45:34,560 - __main__ - INFO - Loading 9216 data
Traceback (most recent call last):
File "/Users/lily/pydev/ash-sage-rc2/01_download-data/physprop/final/filter-data-training.py", line 264, in <module>
main()
File "/Users/lily/micromamba/envs/evaluator-050/lib/python3.11/site-packages/click/core.py", line 1442, in __call__
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/lily/micromamba/envs/evaluator-050/lib/python3.11/site-packages/click/core.py", line 1363, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "/Users/lily/micromamba/envs/evaluator-050/lib/python3.11/site-packages/click/core.py", line 1226, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/lily/micromamba/envs/evaluator-050/lib/python3.11/site-packages/click/core.py", line 794, in invoke
return callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/lily/pydev/ash-sage-rc2/01_download-data/physprop/final/filter-data-training.py", line 239, in main
training_set_frame = curate_data_set(
^^^^^^^^^^^^^^^^
File "/Users/lily/pydev/ash-sage-rc2/01_download-data/physprop/final/filter-data-training.py", line 161, in curate_data_set
curation_schema = CurationWorkflowSchema(
^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/lily/micromamba/envs/evaluator-050/lib/python3.11/site-packages/pydantic/main.py", line 253, in __init__
validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/lily/pydev/openff-evaluator/openff/evaluator/datasets/curation/components/filtering.py", line 798, in _validate_mutually_exclusive
smirks_to_include = values.get("smirks_to_include")
^^^^^^^^^^
File "/Users/lily/micromamba/envs/evaluator-050/lib/python3.11/site-packages/pydantic/main.py", line 989, in __getattr__
raise AttributeError(f'{type(self).__name__!r} object has no attribute {item!r}')
AttributeError: 'FilterByEnvironmentsSchema' object has no attribute 'get'
Closes #677