Fix day-2 cell rehydration and add record-level license default - #326
Merged
Conversation
Resolve cell serials from .battinfo/records/ in a fresh process, and add a workspace-default license (ws.license) stamped onto every saved record and emitted as dcterms:license.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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
Two pre-0.8 package fixes (blind-review findings 3 and 4):
Day-2 workspace rehydration. In a fresh process,
ws.add("test", cell="S1")now resolves a cell whose record sits in.battinfo/records/cell-instance/, instead of raisingCould not resolve cell 'S1' .... The resolver lazily rehydrates the serial index from disk, and the failure message now names what was actually searched.Record-level license. New
ws.license("cc-by-4.0")sets a workspace default that is persisted in.battinfo/workspace.jsonand stamped onto every saved record, so records carry a license by themselves (FAIR R1.1) rather than only on the Zenodo leg.Why
How
Rehydration:
_resolve_cellnow, on a miss, calls_rehydrate_cell_index()(a lazy, once-per-instance scan of.battinfo/records/cell-instance/, sharing the loader core withreload_cells) before falling back to the registry. Error text rewritten to name the saved-records directory and note when the registry is not configured._resolve_test_protocol_ref,_resolve_channel); a cold-process test pins that so it never regresses to the session-only defect the cell path had.License:
ws.license(id|clear=...)mirrorsws.contributor/ws.project: setter/getter/clear, persisted in workspace.json. Known SPDX-ish ids are case-normalized; an unrecognized string is kept verbatim with a warning (never hard-rejected)._record_stamppath so byte-identical re-saves still report[unchanged]; datasets carry it on the existingdataset.licenseslot (leaving an explicitws.add(license=)untouched), other record types at the record top level.dcterms:licenseinrecord_to_jsonld,schema:license/dcterms:licensein the publication bundle.ws.zenodo/preview_jsonldfall back to the workspace default when nolicense=is passed.publication.license_missingwarning (not an error) nudgingws.license(...).licensestring to the cell-spec/cell-instance/test/test-protocol save gates (edited assets/schemas source of truth, re-synced the packaged mirror, ranweb/scripts/sync-schemas.mjs). Datasets already accept a nesteddataset.license.Precedence (documented in the
ws.zenodoandws.adddocstrings): explicitws.zenodo(license=...)> explicitws.add(..., license=...)> workspace default.Public API added (for the docs agent)
ws.license(license: str | None = None, *, clear: bool = False) -> str | None— setter (returns normalized id), getter (no args; returns/prints current or None),clear=Trueto remove. Persisted in.battinfo/workspace.jsonunderlicense; stamped onto every record onws.save().ws.zenodo(..., license: str | None = None)— waslicense: str = "cc-by-4.0"; now defaults to the workspace default, thencc-by-4.0.ws.add("test", ..., license=...)— unchanged, still overrides the workspace default for that record's datasets.ws.zenodo(license=)>ws.add(license=)>ws.license()default.Testing
uv run pytest— 1621 passed, 1 skipped.uv run ruff checkclean on all changed files (pre-existing notebook/demo lint in docs/ and demo/ is untouched and out of territory).uv run mypy— success, 69 files.tests/test_ws_rehydration.py: cold-subprocess resolve of a cell serial saved in a prior process; fresh-instance resolve; truthful error text; cold-process protocol-reference resolve.tests/test_ws_license.py: setter/getter/persistence/clear, case-normalization, unknown-kept-verbatim-with-warning, URL verbatim, stamping into every saved record +record_to_jsonld, no-license-means-no-stamp, explicit-add-overrides-default precedence, preview bundle carries the license,ws.zenododefault resolution + explicit override, missing-license warning nudge + no-nudge-when-present.tests/test_pkg_silent_loss.py: identical re-save with license set ->[unchanged](bytes + mtimes unchanged); changing the workspace license ->[updated].Rehydration repro (registry_url=None), before vs after:
Before: session B (fresh process) ->
ValueError: Could not resolve cell 'S1' in this session, locally, or the registry. Create it with ws.add('cell', ...), or check the serial.After: session B (fresh process) -> resolves S1 and creates the test; an unknown serial now errors with
... in this session, the records saved under <root>\.battinfo\records (registry not configured). ....Pre-existing flakes: none observed. Both full-suite runs (before and after adding tests) were fully green; the documented intermittent rehydrate/finalize flakes did not appear, so nothing needed diffing against main.