Skip to content

Conversation

@htahir1
Copy link
Contributor

@htahir1 htahir1 commented Nov 26, 2025

Just running this to run tests

Sets were documented as a supported MetadataType but failed during serialization because json.dumps() cannot serialize Python sets. This change adds a helper function to convert sets (and tuples) to lists before JSON serialization, making them compatible with JSON while preserving type information via MetadataTypeEnum.

Fixes #4248

Pre-requisites

Please ensure you have done the following:

  • I have read the CONTRIBUTING.md document.
  • I have added tests to cover my changes.
  • I have based my new branch on develop and the open PR is targeting develop. If your branch wasn't based on develop read Contribution guide on rebasing branch to develop.
  • IMPORTANT: I made sure that my changes are reflected properly in the following resources:
    • ZenML Docs
    • Dashboard: Needs to be communicated to the frontend team.
    • Templates: Might need adjustments (that are not reflected in the template tests) in case of non-breaking changes and deprecations.
    • Projects: Depending on the version dependencies, different projects might get affected.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Other (add details above)

@htahir1 htahir1 requested a review from schustmi November 26, 2025 11:36
@github-actions github-actions bot added the internal To filter out internal PRs and issues label Nov 26, 2025
@htahir1 htahir1 force-pushed the claude/zenml-issue-4248-01FHgBjs7uLxfNF5oP7incqW branch from 084095b to fcda9c8 Compare November 26, 2025 11:38
return typed_value # type: ignore[no-any-return]


def serialize_metadata_value(value: MetadataType) -> str:
Copy link
Contributor

@schustmi schustmi Nov 26, 2025

Choose a reason for hiding this comment

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

This is not a good implementation. It does cover top-level sets, but for example fails if it's nested in some other element like a dictionary or list. There is a way to do this natively with json encoders, and there even is a pydantic encoder that we use in our code to solve this in other places.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 26, 2025

Documentation Link Check Results

Absolute links check failed
There are broken absolute links in the documentation. See workflow logs for details
Relative links check passed
Last checked: 2025-11-26 13:18:41 UTC

@htahir1 htahir1 force-pushed the claude/zenml-issue-4248-01FHgBjs7uLxfNF5oP7incqW branch 3 times, most recently from 04e40e1 to ffa80a5 Compare November 26, 2025 11:48
Sets were documented as a supported MetadataType but failed during
serialization because json.dumps() cannot serialize Python sets. This
change uses the standard pydantic_encoder to convert sets (and tuples)
to lists before JSON serialization, making them compatible with JSON
while preserving type information via MetadataTypeEnum.

The fix uses pydantic_encoder directly (via json.dumps(value,
default=pydantic_encoder)) at all serialization points, following the
same pattern used throughout the ZenML codebase. This ensures
consistency and proper handling of all supported types including nested
sets/tuples, UUIDs, datetimes, etc.

Changes:
- Update validate_metadata() in metadata_types.py to use pydantic_encoder
- Update Client.create_run_metadata() to use pydantic_encoder
- Update SQLZenStore.create_run_metadata() to use pydantic_encoder
- Add unit tests for set/tuple validation
- Document supported metadata types in user guide

Fixes #4248
@htahir1 htahir1 force-pushed the claude/zenml-issue-4248-01FHgBjs7uLxfNF5oP7incqW branch from ffa80a5 to 6b41e90 Compare November 26, 2025 11:48
@htahir1 htahir1 requested a review from schustmi November 26, 2025 11:49
@htahir1 htahir1 linked an issue Nov 26, 2025 that may be closed by this pull request
1 task
@htahir1 htahir1 merged commit 1fb40b4 into develop Nov 26, 2025
51 of 54 checks passed
@htahir1 htahir1 deleted the claude/zenml-issue-4248-01FHgBjs7uLxfNF5oP7incqW branch November 26, 2025 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal To filter out internal PRs and issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow sets on Metadata

4 participants