Python(feat): accept list values for multi-value metadata writes - #709
Draft
dengjonathan wants to merge 1 commit into
Draft
Python(feat): accept list values for multi-value metadata writes#709dengjonathan wants to merge 1 commit into
dengjonathan wants to merge 1 commit into
Conversation
metadata_dict_to_proto now accepts list[str] values, emitting one MetadataValue per element in list order (the canonical order). Lists must be non-empty and string-only, mirroring the backend rule that only string keys are multi-value capable. Run and Asset create/update models widen their metadata annotation to dict[str, str | float | bool | list[str]] and gain a before-validator that expands Metadata mappings via expand_metadata_for_write, so update(metadata=entity.metadata) round-trips without dropping values behind getall(). The streaming run form (_to_rust_form) rejects list values with a clear error until the Rust bindings support multi-value. Linear: ENG-13281 (Phase 3) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
|
Python docs preview: https://sift-stack.github.io/sift/python/pr-709/ Deployed from |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Stacked on #699 (read side). Completes the client story for multi-value metadata: list values can now be written through the public API.
metadata_dict_to_protoacceptslist[str]values, emitting oneMetadataValueper element in list order (the canonical order). Lists must be non-empty and string-only, mirroring the backend rule that only string keys are multi-value capable. The parameter widens toMappingso existing scalar-dict callers typecheck unchanged.RunCreate/RunUpdate/AssetUpdatewidenmetadatatodict[str, str | float | bool | list[str]]and gain a before-validator that expandsMetadatamappings via the newexpand_metadata_for_writehelper. Without it, pydantic's dict rebuild (and themodel_dumpfeeding proto conversion) flattens the mapping to its first-value view — soupdate(metadata=run.metadata)would silently drop values. With it, the round-trip is lossless._to_rust_form) rejects list values with a clear error until the Rust bindings support multi-value.Scope
Run and Asset writes only — the entities in the ENG-13281 rollout. Report, channel, test-report, and calculated-channel models keep scalar annotations; widening them later is a per-model annotation + validator once backend support is confirmed.
Testing
test_metadata.py(list conversion order, round-trip,Metadataexpansion, empty-list and non-string rejection),test_run.py(create/update list writes,Metadataround-trip, rust-form guard),test_asset.py(list writes,Metadataround-trip). Full non-integration suite: 1139 passed.TestMultiValueMetadatagains public-write coverage —test_update_run_with_list_metadataandtest_metadata_round_trip_preserves_all_values— verified green against a local stack with themulti-value-metadataflag enabled (skip cleanly when it isn't). Fulltest_runs.pyintegration file: 33 passed.ruff check/ruff format --check/mypy/pyrightclean; regenerated sync stubs unchanged.Linear: ENG-13281 (Phase 3)
🤖 Generated with Claude Code