Add HDMF ↔ LinkML mapping conventions and the base.yaml / CSRMatrix fixtures - #1492
Add HDMF ↔ LinkML mapping conventions and the base.yaml / CSRMatrix fixtures#1492rly wants to merge 4 commits into
Conversation
Document how HDMF Schema Language constructs map to LinkML for the initial scope (base.yaml and CSRMatrix, as a minimal test namespace), and add it to the docs toctree. Addresses #1487. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #1492 +/- ##
=======================================
Coverage 93.16% 93.16%
=======================================
Files 41 41
Lines 10259 10259
Branches 2122 2122
=======================================
Hits 9558 9558
Misses 422 422
Partials 279 279 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@jwbear This is an initial pass of a document that describes the mapping between HDMF Schema Language and LinkML. Please translate |
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
@rly This is a nice reference, but in a CR isn't readily testable or verifiable. It might be helpful if you changed each of the actual requirements into a method stub or unit test that can be run to validate local criteria before a full compilation. |
Hand-author the LinkML files for a minimal hdmf-common test namespace that references only base.yaml and sparse.yaml, following the mapping conventions, plus the companion hdmf-linkml-types schema defining the HDMFSL dtypes. These are the fixtures the LinkML reader and writer are tested against. Add a linkml optional dependency group providing linkml-runtime, and tests that load the fixtures under SchemaView and check that they carry every field of the Spec objects HDMF loads natively from the HDMFSL sources. Running the conventions through linkml-runtime settled several points the doc left open or stated incorrectly, so the doc is updated to match the fixtures: the name identifier slot is declared once per hierarchy root and inherited; dtype synonyms are distinct named types so the HDMFSL spelling survives, while float, double, date, and datetime are reused from linkml:types; attribute required is always written explicitly; defaults are omitted so the Spec dict comparison holds. The worked examples are literalincludes of the fixtures. Addresses #1488. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Fixes #1487
Fixes #1488
Motivation
This adds the initial HDMF ↔ LinkML mapping conventions document together with the hand-authored LinkML translation of a minimal test namespace that applies them, the first two deliverables of the "Read and write LinkML schema for HDMF (CSRMatrix / base.yaml)" epic (#1486). Before any reader or writer is built, we need an agreed, written contract for how HDMF Schema Language (HDMFSL) constructs map to LinkML, and fixtures that prove the contract is real.
The two were originally separate issues. They are combined here because a conventions document that nothing has ever parsed is not a verifiable deliverable, and because running the conventions through
linkml-runtimechanged several of them. Fixing the doc before it merges is cheaper than amending it right after.The scope is the constructs used by
base.yaml(Data,Container,SimpleMultiContainer) andsparse.yaml(CSRMatrix), packaged as a minimal test namespace. What is out of scope is listed explicitly so the doc is not mistaken for a complete mapping.What is here
docs/source/linkml_mapping.rst, added to the "Resources" toctree.tests/unit/linkml_tests/fixtures/:namespace.yaml,base.yaml,sparse.yaml, and the companionhdmf-linkml-types.yamldefining the HDMFSL dtypes.linkmloptional dependency group (linkml-runtime), wired intoall,tox.ini, and the coverage workflow. The core install is unaffected and the tests skip when it is absent.tests/unit/linkml_tests/test_fixtures.py: the fixtures load underSchemaView, every range resolves, the dtype schema coversDtypeHelper.valid_primary_dtypes, and every field of theSpecobjects HDMF loads natively from hdmf-common is present in the LinkML.The coverage tests walk the natively loaded
Specobjects rather than a hand-copied expectation, so a change tobase.yamlorsparse.yamlthat the fixtures do not follow fails here. The worked examples in the doc areliteralincludes of the fixture files, so the documented example cannot drift from what is tested.Conventions that changed once they were run through linkml-runtime
nameidentifier slot is declared once at each hierarchy root (Data,Container) and inherited viais_a. LinkML permits at most one identifier per class, so redeclaring it on every subclass was redundant.Specstores whichever spelling the schema used, so collapsinguintontouint32would rewrite the dtype on the way back and break the comparison. A synonym'stypeofpoints at its primary, which records the synonym relationship in LinkML itself.float,double,date, anddatetimeare reused fromlinkml:typesrather than redefined. They collide by name with LinkML built-ins whose semantics agree (xsd:floatis 32 bit,xsd:doubleis 64 bit), and redefining them would shadow the built-ins for every schema in the import closure.requiredis always written explicitly on an attribute slot. HDMFSL defaults an attribute to required while LinkML defaults a slot to optional, so an omittedrequiredwould flip the meaning.Specsubclassesdictand inheritsdictequality, so the comparison is over the keys actually present. The doc now states the two consequences for the reader: defaults stay absent (noquantity: 1, no explicit defaultrequired), and order withinattributes/datasets/groupsis preserved.docas the slotdescription. The original example dropped it.nameanddefault_nameon a type map toequals_stringandifabsenton the identifier slot. Issue Define the initial HDMF → LinkML mapping conventions #1487 asked for these; neither is exercised by the types in scope, so both are stated as the convention.AnyTypeis called out as the one class range that does not mean adata_type_inc.How to test the behavior
Verified: 14 tests pass (40 subtests), the full unit suite passes (1979 passed), the tests skip cleanly when
linkml-runtimeis not installed, ruff and codespell are clean, and the docs build with-Wand 0 warnings.Checklist
CHANGELOG.md?