Commit 1fb40b4
Fix set serialization in metadata system (#4249)
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
Co-authored-by: Claude <[email protected]>1 parent d8bd68a commit 1fb40b4
File tree
5 files changed
+87
-3
lines changed- docs/book/how-to/metadata
- src/zenml
- metadata
- zen_stores
- tests/unit/metadata
5 files changed
+87
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
25 | 29 | | |
26 | 30 | | |
27 | 31 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5498 | 5498 | | |
5499 | 5499 | | |
5500 | 5500 | | |
| 5501 | + | |
5501 | 5502 | | |
5502 | 5503 | | |
5503 | 5504 | | |
5504 | 5505 | | |
5505 | 5506 | | |
5506 | | - | |
| 5507 | + | |
| 5508 | + | |
| 5509 | + | |
| 5510 | + | |
5507 | 5511 | | |
5508 | 5512 | | |
5509 | 5513 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
234 | 235 | | |
235 | 236 | | |
236 | 237 | | |
237 | | - | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
238 | 242 | | |
239 | 243 | | |
240 | 244 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7183 | 7183 | | |
7184 | 7184 | | |
7185 | 7185 | | |
| 7186 | + | |
| 7187 | + | |
7186 | 7188 | | |
7187 | 7189 | | |
7188 | 7190 | | |
| |||
7191 | 7193 | | |
7192 | 7194 | | |
7193 | 7195 | | |
7194 | | - | |
| 7196 | + | |
7195 | 7197 | | |
7196 | 7198 | | |
7197 | 7199 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
0 commit comments