-
Notifications
You must be signed in to change notification settings - Fork 674
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
[Core feature] Support both pydantic 1.x and 2.x. TypeEngine BaseModelTransformer #5033
Comments
Hey @Future-Outlier! 🚀 Great to see you diving into another interesting challenge with us. How've you been since our last tech adventure? 🛠️ To support both 1.x and 2.x versions of Pydantic in the Flyte repository, we can implement a version-aware mechanism. This mechanism will determine the installed version of Pydantic at runtime and use the appropriate transformers accordingly. Here's a high-level overview of the steps involved:
dependencies = [
'googleapis-common-protos',
'protoc-gen-openapiv2',
'protobuf>=4.21.1,<5.0.0',
'pydantic>=1.0,<3.0', # This line supports both 1.x and 2.x versions
]
import pydantic
# Determine the major version of Pydantic
pydantic_version = int(pydantic.__version__.split('.')[0])
if pydantic_version == 1:
# Define or import transformers and functionality specific to Pydantic 1.x
from .transformers_v1 import MyTransformer
elif pydantic_version == 2:
# Define or import transformers and functionality specific to Pydantic 2.x
from .transformers_v2 import MyTransformer
else:
raise ImportError("Unsupported version of Pydantic")
# Use MyTransformer as needed in your application
Unfortunately, I couldn't find specific details about the current method of handling Pydantic in the Flyte codebase. If you could provide more information about this, it would be helpful in tailoring a more specific solution. Sources
|
update: we decided to deprecate pydantic v1 plugin. |
Motivation: Why do you think this is important?
Now, we can only support 1.x version in pydantic.
However, some users might want to use 2.x version.
Goal: What should the final outcome look like, ideally?
We should support both version with 2 type transformer.
Maybe we need to implement some kind of routing mechanism to recognize which transformer we should use.
Describe alternatives you've considered
When using pydantic version >= 2, only use
pydantic.v1
BaseModel.Propose: Link/Inline OR Additional context
Are you sure this issue hasn't been raised already?
Have you read the Code of Conduct?
The text was updated successfully, but these errors were encountered: