Skip to content

DO NOT MERGE: check #1886 schemaKey handling against dandi-schema #419#1888

Draft
candleindark wants to merge 4 commits into
dandi:masterfrom
candleindark:test-consolidated-dandischema-schemakey
Draft

DO NOT MERGE: check #1886 schemaKey handling against dandi-schema #419#1888
candleindark wants to merge 4 commits into
dandi:masterfrom
candleindark:test-consolidated-dandischema-schemakey

Conversation

@candleindark

Copy link
Copy Markdown
Member

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 dandischema dependency at the dandi-schema #419 consolidate-models branch, where BareAsset.schemaKey is "BareAsset" (instead of "Asset").

That is the condition #1886 addresses. With the changes in the dandi-schema #419 branch, metadata gathered as a BareAsset carries schemaKey="BareAsset", and #1886 resets schemaKey to "Asset" before the metadata is written to an asset endpoint, allowing test_upload_download to 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-api image (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 use BareAsset, and Asset / PublishedAsset behave the same under dandischema==0.12.1 and the dandi-schema #419 branch, so the archive treats the uploaded metadata identically either way. The branch also keeps DANDI_SCHEMA_VERSION == "0.7.0", matching the archive, so the upload path is not disturbed.

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>
@candleindark candleindark added the internal Changes only affect the internal API label Jul 8, 2026
@codecov

codecov Bot commented Jul 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.87%. Comparing base (3f2b6d1) to head (0cf9beb).

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     
Flag Coverage Δ
unittests 76.87% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

`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".
@candleindark candleindark force-pushed the test-consolidated-dandischema-schemakey branch from 52560ff to 783bf19 Compare July 8, 2026 01:26
candleindark and others added 2 commits July 8, 2026 13:28
… 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>
@candleindark candleindark force-pushed the test-consolidated-dandischema-schemakey branch from e134d37 to 0cf9beb Compare July 8, 2026 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal Changes only affect the internal API

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant