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

fix:refactored pydantic extension registration #1152

Merged
merged 3 commits into from
Sep 23, 2024

Conversation

zilto
Copy link
Collaborator

@zilto zilto commented Sep 23, 2024

The merge of #1121 broke Hamilton for users of pydantic<2.0 because the extension was checking for importing Pydantic but had no guard for from pydantic import TypeAdapter a feature added in 2.0. Simply having pydantic<2.0 in your environment broke Hamilton even if not using Pydantic in the Hamilton code because of eager/greedy plugin registration. Problem was larger because registration don't follow the main hamilton/plugins/XX_extensions mechanism.

Change

  • moved the code to hamilton/plugins/pydantic_extensions so that autoload can be disabled or enabled selectively
  • added a try/except for pydantic 2.0 feature with a helpful message
  • changed message from the logger to raise to follow convention amongst plugin

Otherwise, the SchemaValidatorIbis under hamilton.plugins.ibis_extensions is a more modern and safer approach to follow than the older hamilton.data_quality.pandera_validators alternative.

Testing

  • manually check if able to from hamilton import driver and build a Driver for: no pydantic installed, pydantic==1.10 installed, and latest pydantic installed.

@zilto zilto added the bug Something isn't working label Sep 23, 2024
@elijahbenizzy elijahbenizzy merged commit 1365e88 into main Sep 23, 2024
24 checks passed
@elijahbenizzy elijahbenizzy deleted the fix/pydantic-extension branch September 23, 2024 18:55
elijahbenizzy pushed a commit that referenced this pull request Sep 23, 2024
* refactored pydantic extension registration

* delete data_quality/pydantic_validators, content moved to plugins/pydantic_extensions

* added pydantic 2.0 requirements to docstrings

---------

Co-authored-by: zilto <tjean@DESKTOP-V6JDCS2>
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 this pull request may close these issues.

2 participants