Added support for Enum types in Pydantic models#3391
Open
AdilFayyaz wants to merge 2 commits intomasterfrom
Open
Added support for Enum types in Pydantic models#3391AdilFayyaz wants to merge 2 commits intomasterfrom
AdilFayyaz wants to merge 2 commits intomasterfrom
Conversation
Signed-off-by: M. Adil Fayyaz <62440954+AdilFayyaz@users.noreply.github.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3391 +/- ##
===========================================
- Coverage 95.82% 47.80% -48.02%
===========================================
Files 5 216 +211
Lines 527 22782 +22255
Branches 0 2998 +2998
===========================================
+ Hits 505 10892 +10387
- Misses 22 11295 +11273
- Partials 0 595 +595 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tracking issue
Duplicated from: flyteorg/flyte-sdk/pull/622
Why are the changes needed?
Ensure flytekit versions alongside flytesdk
What changes were proposed in this pull request?
In
generate_attribute_list_from_dataclass_json_mixin(), when a $ref resolves to an enum definition (has enum key, no properties), map the field to str instead of trying to construct a dataclass from it. Previously this crashed with KeyError: 'properties' because the code assumed every $ref pointed to a model.How was this patch tested?
Test (test_enum_in_pydantic.py): Defines a Job(BaseModel) with a Status(str, Enum) field, roundtrips it through to_literal_type -> to_literal -> to_python_value -> guess_python_type, and verifies the guessed dataclass accepts enum values as strings.
Setup process
Screenshots
Check all the applicable boxes
Related PRs
Docs link