feat: pluggable external metadata sources — Protocol, registry, resolver hook (#784) - #1106
Merged
Merged
Conversation
…ver hook (#784) - cellpy.readers.metadata_sources: MetadataSource / SupportsMetadataPush Protocols, MetaQuery, MetaRecord, ExternalLink, validate_record, error hierarchy; cellpy.metadata_sources entry-point registry (register, names, get_source); null-object fetch_meta (unknown/unreachable => empty layer, auth errors propagate); conformance kit check_metadata_source - MetaResolver.resolve(external=...): records join the journal/db layer below the journal row; Resolution.origins / origin_of / explain() name the winning source - CellpyCell.fetch_meta(source, key=None, kind=, apply=, strict=) and external_links; Data.external_links persisted in v9 meta.json - tests/test_metadata_sources.py (36, 6 essential); docs, HISTORY, design note; CellMeta.uuid filed core-first as cellpy/cellpy-core#151 Closes #784 Co-authored-by: Cursor <cursoragent@cursor.com>
10 of 21 tasks
This was referenced Sep 26, 2026
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.
Closes #784 — Epic M / M1 (stage 4 of #783), read path only. Non-yolo: public Protocol + resolver precedence, so this PR is the review point and is not auto-merged.
What
cellpy.readers.metadata_sources(new package)MetadataSourceProtocol (name: ClassVar[str],fetch(MetaQuery) -> tuple[MetaRecord, ...]),SupportsMetadataPushdeclared for M3 (unused).MetaQuery,MetaRecord(draftcell/testmappings +external_id/source_uri),ExternalLink(persisted back-link),validate_record(unknown fields, pre-filled provenance andNonevalues are contract violations).cellpy.metadata_sourcesentry-point registry mirroring the loader registry: lazy, broken plugins skipped with a warning,register()for tests/notebooks,get_source()instantiates once.fetch_meta(source, query, strict=False): null object — unknown/unreachable source or invalid record ⇒()+ warning;MetadataSourceAuthErroralways propagates.testing.check_metadata_sourceconformance kit +DictMetadataSourcefake.MetaResolver.resolve(external=…)(alsoresolve_cell_meta/resolve_test_meta/resolve_from_loader_result): external records join the journal/db layer below the journal row (kwargs > journal row > external sources in priority order > raw file > defaults).Resolution.origins,origin_of(),fields_from_origin();explain()printsmass: journal/db (batbase). Old shape unchanged without externals.CellpyCell.fetch_meta(source, key=None, *, kind="cell_name", project=, apply=True, strict=False, **extra)+external_linksproperty. Applies the first record via the resolver →apply_test_meta_to_legacy(engine's live boxes), recordsExternalLink(fields=applied).Data.external_linkspersisted in v9meta.jsonunder"external_links"; copied byfrom_cell.Decisions (see
.issueflows/04-designs-and-guides/metadata-sources.md)Layerenum member — contributors +originskeepLayerordering stable.CellMeta.uuidlives in cellpy-core → filed core-first as CellMeta.uuid: cell-level join key for external metadata sources cellpy/cellpy-core#151 rather than changed here.batch.from_source, multi-source config, cache/TTL, push, BattINFO vocabulary map.Tests
tests/test_metadata_sources.py: 36 tests, 6essential(contract shape, null object, auth propagation, precedence + provenance, cell surface).uv run pytest -m essential: 959 passed.Docs
HISTORY,
docs/api/readers.md,docs/agents/index.md,AGENTS.mdagents section, test registry.Next
cellpy/cellpy-connectors#2 (M2, BatBase
MetadataSourceadapter overBatBaseClient, registered via the entry point).Made with Cursor