DO NOT MERGE: check #1886 schemaKey handling against dandi-schema #419#1888
Draft
candleindark wants to merge 4 commits into
Draft
DO NOT MERGE: check #1886 schemaKey handling against dandi-schema #419#1888candleindark wants to merge 4 commits into
candleindark wants to merge 4 commits into
Conversation
Whatever the metadata was gathered as (e.g. a BareAsset), what is created on the server is an Asset. The server stores schemaKey verbatim and does not normalize it, so set it at the point of upload rather than relying on the caller. This matters because dandi-schema is changing BareAsset.schemaKey from "Asset" to "BareAsset". Metadata gathered via a BareAsset then serializes with schemaKey="BareAsset", so an asset created or updated from it would be stored with the wrong schemaKey. Pin it at every asset-endpoint write: iter_upload (LocalFileAsset, ZarrAsset) and set_raw_metadata (RemoteBlobAsset, RemoteZarrAsset); the latter is reached by the reextract command without going through iter_upload. A no-op against the current dandi-schema release (where BareAsset.schemaKey is still "Asset"), so it can ship first. Co-Authored-By: Claude Code 2.1.202 / Claude Opus 4.8 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 @@
## master #1888 +/- ##
==========================================
- Coverage 76.88% 76.87% -0.01%
==========================================
Files 88 88
Lines 12901 12909 +8
==========================================
+ Hits 9919 9924 +5
- Misses 2982 2985 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
`test_nwb2asset` and `test_nwb2asset_remote_asset` compared the `nwb2asset()` result against a `BareAsset` built with an explicit `schemaKey="Asset"`, which just restates the field default. `model_construct()` fills defaults in, so dropping it is a no-op against the current dandischema and ensures the equalities continue to hold once dandi-schema#419 lands, where `BareAsset.schemaKey` becomes "BareAsset".
52560ff to
783bf19
Compare
3 tasks
… value `prepare_metadata()` returns a `BareAsset`, whose top-level `schemaKey` is `"Asset"` with the current dandischema but `"BareAsset"` under dandi/dandi-schema#419 (which pins `BareAsset.schemaKey` to its class name). To keep this test passing against either dandischema version, the expected `schemaKey` is set to the default of the `schemaKey` field in `BareAsset` before the comparison, and the four `metadata2asset*.json` files now store a placeholder for the field. The later `validate()` call checks the data against the `Asset` class, so `data_as_dict` is promoted to an Asset (`schemaKey = "Asset"`) beforehand.
Temporarily point the dandischema dependency at the consolidate-models branch (dandi/dandi-schema#419), where BareAsset.schemaKey is "BareAsset", so CI runs the dandi-cli client against the consolidated schema and checks that this branch still uploads schemaKey="Asset". For checking the test outcome only; not intended to be merged. Co-Authored-By: Claude Code 2.1.202 / Claude Opus 4.8 claude-opus-4-8 <noreply@anthropic.com>
e134d37 to
0cf9beb
Compare
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.
Not for merging
This PR exists only to check the test outcome for #1886 with the changes in the dandi-schema #419 branch incorporated. It is not meant to be merged.
What this does
Branches off #1886 and temporarily repoints the
dandischemadependency at the dandi-schema #419consolidate-modelsbranch, whereBareAsset.schemaKeyis"BareAsset"(instead of"Asset").That is the condition #1886 addresses. With the changes in the dandi-schema #419 branch, metadata gathered as a
BareAssetcarriesschemaKey="BareAsset", and #1886 resetsschemaKeyto"Asset"before the metadata is written to an asset endpoint, allowingtest_upload_downloadto pass with the changes in dandi-schema #419.Why the archive's dandischema version does not affect the test
In this PR's CI, only the client (dandi-cli) picks up the dandi-schema #419 branch; the test archive is the stock
dandiarchive/dandiarchive-apiimage (dandischema==0.12.1). (Eventually dandi-archive will adopt the dandi-schema #419 changes too.) That the archive still runs the older dandischema does not matter here: dandi-archive does not useBareAsset, andAsset/PublishedAssetbehave the same underdandischema==0.12.1and the dandi-schema #419 branch, so the archive treats the uploaded metadata identically either way. The branch also keepsDANDI_SCHEMA_VERSION == "0.7.0", matching the archive, so the upload path is not disturbed.