Python(feat): expose multi-value metadata via a Metadata mapping with getall - #699
Draft
dengjonathan wants to merge 3 commits into
Draft
Python(feat): expose multi-value metadata via a Metadata mapping with getall#699dengjonathan wants to merge 3 commits into
dengjonathan wants to merge 3 commits into
Conversation
… getall metadata_proto_to_dict now returns Metadata, a dict subclass whose scalar view keeps the first value per key (unchanged for existing callers) and whose getall(key) returns the full ordered value list. Run/Asset/Report/Channel .metadata fields adopt the type, with a pydantic core-schema hook so validation passes instances through instead of rebuilding them as plain dicts (which would drop the extra values). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
|
Python docs preview: https://sift-stack.github.io/sift/python/pr-699/ Deployed from |
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Seeds duplicate-key metadata through the raw UpdateRun proto (the public write path is scalar-only until ENG-13281 Phase 3) and asserts the full read-side contract: Metadata type, scalar first-value view, getall order, and the first-value invariant. Skips cleanly against backends without the multi-value-metadata flag so CI stays green until flag GA. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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 #698 (crash fix). That PR makes multi-value metadata safe to fetch; this one makes it usable: values beyond the first are no longer invisible to client code.
metadata_proto_to_dictnow returnsMetadata, adictsubclass:.get(), iteration,==,isinstance(md, dict),json.dumps) behaves exactly as before. Invariant:md[k] == md.getall(k)[0].Run/Asset/Report/Channel.metadatafields adopt the type. A__get_pydantic_core_schema__hook passesMetadatainstances through validation untouched — without it, pydantic rebuilds the field as a plain dict and silently drops the extra values. Serialization (model_dump/model_dump_json) still emits a plain first-value dict, so dumped output is unchanged.getlist, aiohttpgetall, stdlibemail.get_all);getallmatches aiohttp's spelling. Same contract as the rule-payloadMetadatashipping in azimuth (ENG-13104), so rule code, canvas code, and client scripts share one metadata API.Scope
Read side only. The write path (accepting list values in
metadata_dict_to_proto/ update models) is Phase 3 of ENG-13281.Testing
_tests/util/test_metadata.pygrows from 4 to 13 tests:getallordering/copy/fallback semantics, first-value invariant, JSON serializability, and pydantic field behavior (instance pass-through preserving lists, plain-dict wrapping, non-mapping rejection,model_dumpoutput). Also verified end-to-end thatRun._from_protowith duplicate-key metadata yieldsmetadata.getall(...)with the full list.ruff check/ruff format --checkpass at the pinned version (0.12.12); generated sync stubs don't reference the changed annotations.Linear: ENG-13281 (Phase 2)
🤖 Generated with Claude Code