feat: BatBase MetadataSource adapter for cellpy (#2) - #9
Merged
Merged
Conversation
- BatBaseMetadataSource satisfies cellpy's MetadataSource Protocol and is registered under the cellpy.metadata_sources entry point as 'batbase' - journal_row_to_meta maps /api/test-cellpy-journal/ rows to CellMeta / TestMeta fields (mass, tot_mass, area, loading, nom_cap + unit conversion and nom_cap_specifics, cell_type, cycle_mode, cell_name, comment, schedule_file_name); cellpy-free and tolerant of missing keys - query kinds: cell_name (label/name/device_name, cached listing), tag (server filter with project, tag id, unscoped name), external_id, test_name - ConnectorAuthError -> MetadataSourceAuthError (never swallowed); other ConnectorError -> MetadataSourceError (cellpy degrades to empty layer) - 29 tests (20 skip without cellpy #784); docs and design note - API gap for journal annotations filed as ife-bat/batbase#473 Closes #2 Co-authored-by: Cursor <cursoragent@cursor.com>
10 of 21 tasks
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 #2 — Epic M / M2 (stage 4 of jepegit/cellpy#783). Depends on #1 (merged) and jepegit/cellpy#1106 (merged). Non-yolo: mapping decisions against an unsettled API, so this is the review point and is not auto-merged.
What
cellpy_connectors/batbase_source.pyBatBaseMetadataSource(name = "batbase",fetch(MetaQuery) -> tuple[MetaRecord, ...]) overBatBaseClient; no credentials or token logic here. Client built lazily on first use so the registry can instantiate it without credentials present.cell_name(default — journallabel, elsename, elsedevice_name, matched client-side over a per-instance cached listing, 300 s),tag(project⇒ server-sidecellpy_tag__name+cellpy_tag__project; numeric key = tag id; unscoped name resolved viatest-cellpy-tagacross visible projects),external_id(one row; 404 ⇒()),test_name. Unknown kinds ⇒().journal_row_to_meta(row)— pure, cellpy-free field/unit/vocabulary map:mass,total_mass→tot_mass,area→active_electrode_area,loading→active_electrode_loading,nominal_capacity_value+unit→nom_capin mAh/g | mAh/cm² | mAh +nom_cap_specifics,cell_typehc/fc/3e/sym → half_cell/…,test_mode→cycle_mode(anode / cathode / full),label→cell_name,comments,test_schedule. Never emitsNone; never fills provenance (instrumentstays inraw).ConnectorAuthError→MetadataSourceAuthError(cellpy never swallows it); otherConnectorError→MetadataSourceError(cellpy'sfetch_metadegrades to an empty layer).pyproject.toml:[project.entry-points."cellpy.metadata_sources"] batbase = ….fetch).BatBase API gap
/api/test-cellpy-journal/serializes model fields only; the journal-table annotations (mass,total_mass,area,loading,nom_cap,cell_type) and name filters are not on the API. Filed as ife-bat/batbase#473. The mapping already reads those keys, so records carry label / nominal capacity / test mode / schedule / comments today and gain mass etc. when #473 ships — no adapter change needed.Tests
tests/test_batbase_source.py: 29 tests — mapping/units/vocabulary (cellpy-free), lazy client, cache, and cellpy-dependent Protocol / entry-point /check_metadata_sourceconformance / error translation / end-to-endCellpyCell.fetch_meta("batbase")applying mass (skip without cellpy #784).uv run pytestwith sibling cellpy installed: 78 passed.ms.names() == ('batbase',), all query kinds return()cleanly, 404 path clean.Docs
README "As a cellpy metadata source",
this-project.md,.issueflows/04-designs-and-guides/batbase-metadata-source.md, test registry.Made with Cursor