Skip to content

Document validation caveats of the get_metadata methods#1892

Merged
yarikoptic merged 1 commit into
masterfrom
docs-get-metadata-validation-caveats
Jul 20, 2026
Merged

Document validation caveats of the get_metadata methods#1892
yarikoptic merged 1 commit into
masterfrom
docs-get-metadata-validation-caveats

Conversation

@candleindark

Copy link
Copy Markdown
Member

Docstring-only change to RemoteDandiset.get_metadata() and BaseRemoteAsset.get_metadata(). No behavior change.

Both methods validate fetched metadata against the Dandiset/Asset model of the installed dandischema, not against the version of that model the metadata was published under. The existing note only warns that unpublished versions may have invalid metadata, which leaves two things unstated:

  • Even a published version's metadata can fail to validate, because of drift between the model in the installed dandischema and the version of the model the metadata was published under.
  • The methods can raise pydantic.ValidationError when the fetched metadata does not validate against dandischema.models.Dandiset / dandischema.models.Asset.

Both are now documented, the latter as a :raises: field matching the convention already used elsewhere in dandiapi.py.

Test plan

  • pre-commit hooks pass (black, isort, flake8, codespell, reuse lint)
  • flake8 and black --check clean on dandi/dandiapi.py

`RemoteDandiset.get_metadata` and `BaseRemoteAsset.get_metadata` validate the
fetched metadata against the `Dandiset` and `Asset` models of the installed
`dandischema`, not against the version of the model that the metadata was
published under. Drift between the two can render previously-valid metadata
invalid, so even a published version's metadata is not guaranteed to validate.

Document that caveat, and document the `pydantic.ValidationError` that both
methods can raise when the fetched metadata does not validate.

Co-Authored-By: Claude Code 2.1.210 / Claude Opus 4.8 claude-opus-4-8 <noreply@anthropic.com>
@codecov

codecov Bot commented Jul 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.93%. Comparing base (0698b7d) to head (0877531).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1892      +/-   ##
==========================================
- Coverage   76.96%   76.93%   -0.03%     
==========================================
  Files          88       88              
  Lines       12882    12882              
==========================================
- Hits         9914     9911       -3     
- Misses       2968     2971       +3     
Flag Coverage Δ
unittests 76.93% <ø> (-0.03%) ⬇️

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.

@candleindark candleindark added the documentation Changes only affect the documentation label Jul 16, 2026
@candleindark

Copy link
Copy Markdown
Member Author

The failing CI checks here are unrelated to this docstring-only change.

  • codecov/project is a coverage-target miss (expected: a docstring-only diff adds no covered lines), and codecov/patch passed.
  • The only failing test jobs are the two dev-deps variants; every normal, dandi-api, and nfs job passed across all OS/Python combinations. The same dev-deps failures reproduce on master in the scheduled run 29477710764, which does not include this PR, so a docstring change cannot be the cause.
Root cause of the dev-deps failures

The dev-deps jobs install hdmf from git (6.1.1.dev12+g50769ca55), which now emits a new DeprecationWarning while writing an NWB file:

DeprecationWarning: Override function for attribute 'experimenter' returned None, so the container's attribute value is used. In HDMF 8.0, a None return will set the attribute to None; return ObjectMapper.NO_OVERRIDE to keep using the container's attribute value.

Under filterwarnings = error this is promoted to an exception, which aborts the shared NWB-file fixture (dandi/tests/fixtures.pydandi/pynwb_utils.py::make_nwb_fileio.write). Every test that depends on a written NWB file (test_validate_*, test_organize_*, test_video_organize*, test_organized_nwb_dir*, test_get_asset_metadata, test_smoke*) then errors at setup, and the failures cascade to the archive-backed tests. Released hdmf 6.1.0 (used by the pinned-dependency jobs) does not emit this warning, so only dev-deps is affected. This will keep failing until hdmf/pynwb upstream stops emitting the warning or dandi-cli filters it.

@candleindark

Copy link
Copy Markdown
Member Author

Follow-up: the dev-deps failure is already tracked upstream by pynwb PR NeurodataWithoutBorders/pynwb#2224, which migrates the offending override functions (including NWBFileMap.experimenter_obj_attr, the exact one in the traceback) to return ObjectMapper.NO_OVERRIDE instead of None. It depends on the hdmf change that introduced the deprecation (hdmf-dev/hdmf#1167). Nothing to fix in dandi-cli; the dev-deps jobs should go green once those land and dev-deps picks up the new git tips.

@candleindark
candleindark requested a review from yarikoptic July 16, 2026 21:03
@yarikoptic
yarikoptic merged commit 0dce272 into master Jul 20, 2026
61 of 67 checks passed
@yarikoptic
yarikoptic deleted the docs-get-metadata-validation-caveats branch July 20, 2026 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Changes only affect the documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants