-
Notifications
You must be signed in to change notification settings - Fork 2.5k
feat: Add serialization and deserialization of Enum type when creating a PipelineSnaphsot
#9869
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
| def _convert_to_basic_types(value: Any) -> Any: | ||
| """ | ||
| Helper function to recursively convert complex Python objects into their basic type equivalents. |
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.
By handling every base case in _serialize_value_with_schema we no longer need this helper function.
| # def test_serialize_and_deserialize_value_with_enum(): | ||
| # data = CustomEnum.ONE | ||
| # expected = {"serialization_schema": {"type": "test_base_serialization.CustomEnum"}, "serialized_data": "ONE"} | ||
| # assert _serialize_value_with_schema(data) == expected | ||
| # assert _deserialize_value_with_schema(expected) == data |
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 test is currently failing b/c it triggers the elif hasattr(payload, "__dict__"): check and since an Enum object refers to itself within it's __dict__ attributes we get a recursion error.
Pull Request Test Coverage Report for Build 18493209102Details
💛 - Coveralls |
PipelineSnaphsot
| if schema.get("uniqueItems") is True: | ||
| final_array = set(deserialized_items) | ||
| # Is a tuple if minItems and maxItems are set and equal | ||
| elif schema.get("minItems") is not None and schema.get("maxItems") is not None: |
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.
Do we need to explicitly check if minItems and maxItems are equal?
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.
I think checking for them now is enough. This was our check from before, I'll update the comment
Amnah199
left a comment
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.
Thanks for the updates!
Related Issues
Proposed Changes:
_serialize_value_with_schemaand_deserialize_value_with_schematest_base_serialization.pyto reduce duplicate code and to test more scenariosHow did you test it?
Notes for the reviewer
Checklist
fix:,feat:,build:,chore:,ci:,docs:,style:,refactor:,perf:,test:and added!in case the PR includes breaking changes.