Skip to content

Conversation

@sjrl
Copy link
Contributor

@sjrl sjrl commented Oct 13, 2025

Related Issues

Proposed Changes:

  • Simplfying _serialize_value_with_schema and _deserialize_value_with_schema
  • Refactor tests in test_base_serialization.py to reduce duplicate code and to test more scenarios
  • Added support for serializing and deserializing Enum types

How did you test it?

  • New unit tests

Notes for the reviewer

Checklist

  • I have read the contributors guidelines and the code of conduct
  • I have updated the related issue with new insights and changes
  • I added unit tests and updated the docstrings
  • I've used one of the conventional commit types for my PR title: fix:, feat:, build:, chore:, ci:, docs:, style:, refactor:, perf:, test: and added ! in case the PR includes breaking changes.
  • I documented my code
  • I ran pre-commit hooks and fixed any issue

@github-actions github-actions bot added topic:tests type:documentation Improvements on the docs labels Oct 13, 2025
Comment on lines -156 to -158
def _convert_to_basic_types(value: Any) -> Any:
"""
Helper function to recursively convert complex Python objects into their basic type equivalents.
Copy link
Contributor Author

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.

Comment on lines 402 to 406
# 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
Copy link
Contributor Author

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.

@coveralls
Copy link
Collaborator

coveralls commented Oct 13, 2025

Pull Request Test Coverage Report for Build 18493209102

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 24 unchanged lines in 3 files lost coverage.
  • Overall coverage decreased (-0.03%) to 92.032%

Files with Coverage Reduction New Missed Lines %
core/pipeline/async_pipeline.py 3 65.88%
core/pipeline/pipeline.py 5 88.89%
utils/base_serialization.py 16 86.67%
Totals Coverage Status
Change from base Build 18463766988: -0.03%
Covered Lines: 13201
Relevant Lines: 14344

💛 - Coveralls

@sjrl sjrl changed the title WIP: Fix serialization and deserialization of Enum type fix: Fix serialization and deserialization of Enum type Oct 14, 2025
@sjrl sjrl changed the title fix: Fix serialization and deserialization of Enum type feat: Add serialization and deserialization of Enum type when creating a PipelineSnaphsot Oct 14, 2025
@sjrl sjrl marked this pull request as ready for review October 14, 2025 08:39
@sjrl sjrl requested a review from a team as a code owner October 14, 2025 08:39
@sjrl sjrl requested review from Amnah199 and removed request for a team October 14, 2025 08:39
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:
Copy link
Contributor

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?

Copy link
Contributor Author

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

@sjrl sjrl requested a review from Amnah199 October 14, 2025 10:15
Copy link
Contributor

@Amnah199 Amnah199 left a 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!

@sjrl sjrl enabled auto-merge (squash) October 14, 2025 10:28
@sjrl sjrl merged commit 512dd86 into main Oct 14, 2025
19 checks passed
@sjrl sjrl deleted the fix-sede-enum branch October 14, 2025 10:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RecursionError when Pipeline Component with Enum in Data Raises Exception

4 participants