Skip to content

fix: Update the de/serialization with schema utils#9526

Merged
Amnah199 merged 25 commits intomainfrom
update_serialization_schema_util
Jun 24, 2025
Merged

fix: Update the de/serialization with schema utils#9526
Amnah199 merged 25 commits intomainfrom
update_serialization_schema_util

Conversation

@Amnah199
Copy link
Copy Markdown
Contributor

@Amnah199 Amnah199 commented Jun 17, 2025

Related Issues

  • The current serialize function assumes the input is always a dictionary, which is problematic in flexible input scenarios (e.g., breakpoints).

  • When serializing a dictionary, only type: "object" is stored without detailing its structure — properties are missing or incomplete.

Proposed Changes:

  • Refactor serialize to support flexible value types beyond dictionaries.

  • When serializing dictionaries, store as type: "object", properties: "key":"value" to properly describe the schema.

How did you test it?

  • Updated tests
  • Added new tests

Notes for the reviewer

  • It was anticipated that these functions might need to be updated.

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 Jun 17, 2025
@Amnah199 Amnah199 added ignore-for-release-notes PRs with this flag won't be included in the release notes. labels Jun 17, 2025
@Amnah199 Amnah199 marked this pull request as ready for review June 17, 2025 22:06
@Amnah199 Amnah199 requested a review from a team as a code owner June 17, 2025 22:06
@Amnah199 Amnah199 requested review from davidsbatista and sjrl and removed request for a team and davidsbatista June 17, 2025 22:06
Comment thread haystack/utils/base_serialization.py Outdated
Comment thread haystack/utils/base_serialization.py Outdated
Comment thread haystack/utils/base_serialization.py
Comment thread haystack/utils/base_serialization.py Outdated
Comment thread haystack/utils/base_serialization.py Outdated
@sjrl
Copy link
Copy Markdown
Contributor

sjrl commented Jun 18, 2025

@Amnah199 looking really good! A few minor comments and only one slightly larger one here

@coveralls
Copy link
Copy Markdown
Collaborator

coveralls commented Jun 18, 2025

Pull Request Test Coverage Report for Build 15848630494

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 21 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-0.007%) to 90.175%

Files with Coverage Reduction New Missed Lines %
core/pipeline/async_pipeline.py 3 67.74%
utils/base_serialization.py 18 89.09%
Totals Coverage Status
Change from base Build 15846939495: -0.007%
Covered Lines: 11610
Relevant Lines: 12875

💛 - Coveralls

@Amnah199 Amnah199 added this to the 2.15.0 milestone Jun 20, 2025
@Amnah199 Amnah199 self-assigned this Jun 22, 2025
Comment thread haystack/utils/base_serialization.py Outdated
Comment on lines +112 to +113
# Handle Haystack style objects (e.g. dataclasses and Components)
elif hasattr(payload, "to_dict") and callable(payload.to_dict):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is slightly tangential, but could you open a follow up issue to add a to_dict and from_dict method for ByteStream? It's the only dataclass we regularly return from our components that's missing a to_dict and from_dict method.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created the issue here #9543 .

Comment thread haystack/utils/base_serialization.py Outdated
Comment thread haystack/utils/base_serialization.py Outdated
Comment thread haystack/utils/base_serialization.py Outdated
Comment thread haystack/utils/base_serialization.py Outdated
Comment thread test/utils/test_base_serialization.py Outdated
Comment thread haystack/utils/base_serialization.py
Comment thread haystack/utils/base_serialization.py
Comment thread haystack/utils/base_serialization.py Outdated
Comment thread haystack/utils/base_serialization.py
Copy link
Copy Markdown
Contributor

@sjrl sjrl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@Amnah199 Amnah199 merged commit 9ed0b9b into main Jun 24, 2025
17 checks passed
@Amnah199 Amnah199 deleted the update_serialization_schema_util branch June 24, 2025 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ignore-for-release-notes PRs with this flag won't be included in the release notes. topic:tests type:documentation Improvements on the docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants