Commit 04e40e1
committed
Fix set serialization in metadata system
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 #42481 parent b5dfe3f commit 04e40e1
File tree
5 files changed
+116
-4
lines changed- docs/book/how-to/metadata
- src/zenml
- metadata
- zen_stores
- tests/unit/metadata
5 files changed
+116
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
323 | 323 | | |
324 | 324 | | |
325 | 325 | | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
326 | 359 | | |
327 | 360 | | |
328 | 361 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | 17 | | |
19 | 18 | | |
20 | 19 | | |
| |||
5498 | 5497 | | |
5499 | 5498 | | |
5500 | 5499 | | |
| 5500 | + | |
5501 | 5501 | | |
5502 | 5502 | | |
5503 | 5503 | | |
5504 | 5504 | | |
5505 | 5505 | | |
5506 | | - | |
| 5506 | + | |
| 5507 | + | |
| 5508 | + | |
| 5509 | + | |
5507 | 5510 | | |
5508 | 5511 | | |
5509 | 5512 | | |
| |||
| 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 | |
|---|---|---|---|
| |||
7172 | 7172 | | |
7173 | 7173 | | |
7174 | 7174 | | |
| 7175 | + | |
| 7176 | + | |
7175 | 7177 | | |
7176 | 7178 | | |
7177 | 7179 | | |
| |||
7180 | 7182 | | |
7181 | 7183 | | |
7182 | 7184 | | |
7183 | | - | |
| 7185 | + | |
7184 | 7186 | | |
7185 | 7187 | | |
7186 | 7188 | | |
| |||
| 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