Recipes#
What to do, in order, for the changes you want to make. Each ends with the same check:
poetry run pytest && poetry run ruff check . && poetry run mypy
CI additionally runs every generator in --check mode, so a derived file left
stale fails the build.
Add a field to the profile#
Add it to
profile/lumc-codemeta.yamlunderrequired:orrecommended:, withoneormany. Use the bare name if CodeMeta defines it, otherwise prefix it (schema:featureList).If the vocabulary’s own definition would not tell someone how to fill the field in, add a line under
help:.If it can hold a class not already listed under
types:, add that class with the properties worth describing. The generator fails with the class name if you forget.poetry run python scripts/build_schema.py
Nothing else. Types, descriptions and node shapes come from the vocabularies.
Move to a newer CodeMeta#
Change
versionand the URLs under thecodemetaentry inprofile/lumc-codemeta.yaml.Update the two
codemetaentries inscripts/vendoring/sources.py, andCONTEXT_VERSIONSinscripts/vendoring/codemeta.py, to match.poetry run python scripts/vendor_reference_data.pypoetry run python scripts/build_schema.pyRun the suite. Failures are the real report: a property whose type changed upstream shows up as a test that no longer holds.
Renamed properties are not migrated. A record on an older context is reported as unrecognized, which is deliberate: the same file means different things under two vocabularies, and guessing which was meant is worse than saying so.
Add a vocabulary#
For a namespace beyond CodeMeta and schema.org.
Add an entry under
vocabularies:in the profile, with itsprefixand the URLs its properties and classes come from.Add a
Sourcetoscripts/vendoring/sources.pyand a parser module beside it, producing the same shape as the others: property name mapped torangeanddescription.Merge it in
merge_types. Order is precedence, so put it after the vocabularies it should not override.Prefix its fields in the profile and regenerate.
Support a new metadata file#
Check whether CodeMeta already publishes a crosswalk for it, under
crosswalks/. If one exists, add it toCROSSWALK_SOURCESinscripts/vendoring/crosswalks.py, register theSource, and re-run the vendoring script; the mapping’soriginis thenmixed, notrs-metadata. A test enforces both that claim and the coverage below.Write an adapter in
adapters/, subclassingAdapter. See Adapters for what each method owes.Write the crosswalk in
mappings/<id>.yaml. Every concept the upstream table maps must either get a rule or be declared underupstream.omittedwith the reason it is not compared.Register it in
adapters/registry.py. Registration order is reporting order.Add a test in
tests/adapters/that builds a repository and runs the real pipeline.poetry run python scripts/generate_docs.py
Change the anchor format#
This is a substantial change. codemeta.json is the record
the profile is defined against, so replacing it means:
a new anchor adapter, and
ANCHORpointing at it;a context model, if the new format is not JSON-LD —
profile/jsonld.pyassumes it is;new crosswalks, since every mapping translates to CodeMeta concepts;
a profile definition written against the new vocabulary.
The vocabulary layer, the type and format checks, the consistency engine and the reporting all carry over unchanged. Budget for the four above.
Add or change a rule#
Change |
Where |
|---|---|
A structural rule |
|
A rule about meaning |
the matching |
What must agree across files |
the relevant |
A comparison strategy |
|
A diagnostic code |
|
The report shape |
|
A new rule needs a test on both sides: a record that satisfies it, and one that breaks exactly that rule.
Refresh the vendored vocabularies#
poetry run python scripts/vendor_reference_data.py
poetry run python scripts/build_schema.py
poetry run pytest