Skip to content

Fix pynwb.validate() for Zarr-backed NWB files#2187

Open
h-mayorquin wants to merge 2 commits into
devfrom
fix_zarr_validate
Open

Fix pynwb.validate() for Zarr-backed NWB files#2187
h-mayorquin wants to merge 2 commits into
devfrom
fix_zarr_validate

Conversation

@h-mayorquin

Copy link
Copy Markdown
Contributor

I encounter this while working on the inspector NeurodataWithoutBorders/nwbinspector#699

Closes #2131 and #2119.

Calling pynwb.validate() on a Zarr file raised TypeError: ZarrIO.load_namespaces: unrecognized argument: 'driver', unrecognized argument: 'aws_region' because the validator resolved the backend via _get_backend and then unconditionally forwarded HDF5 (Hierarchical Data Format 5) kwargs (driver, aws_region, load_namespaces) into whichever backend it returned, including NWBZarrIO.

The fix follows, to the best of my understanding, @oruebel recommendation here in hdmf-dev/hdmf-zarr#302: rather than scatter backend dispatch across the validator, concentrate backend-specific construction in a single _open_backend_io helper that translates kwargs per backend, and switch namespace loading to HDMFIO.load_namespaces_io on the open IO. This leverages @rly's instance-method API added in hdmf-dev/hdmf#1299 which replaces the classmethod call that required reaching into the private io._file attribute, so the long-standing TODO from #2119 is retired as part of the same change. storage_options is added to the public validate() API so Zarr users can pass fsspec (filesystem spec) config through.

Checklist

  • Did you update CHANGELOG.md with your changes?
  • Have you checked our Contributing document?
  • Have you ensured the PR clearly describes the problem and the solution?
  • Is your contribution compliant with our coding style? This can be checked running ruff check . && codespell from the source directory.
  • Have you checked to ensure that there aren't other open Pull Requests for the same change?
  • Have you included the relevant issue number using "Fix #XXX" notation where XXX is the issue number? By including "Fix #XXX" you allow GitHub to close issue #XXX when the PR is merged.

@codecov

codecov Bot commented May 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.30%. Comparing base (483a4f1) to head (8a617d6).
⚠️ Report is 1 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #2187      +/-   ##
==========================================
+ Coverage   95.29%   95.30%   +0.01%     
==========================================
  Files          30       30              
  Lines        3038     3046       +8     
  Branches      450      451       +1     
==========================================
+ Hits         2895     2903       +8     
  Misses         87       87              
  Partials       56       56              
Flag Coverage Δ
integration 73.21% <100.00%> (+0.07%) ⬆️
unit 86.04% <95.23%> (+0.06%) ⬆️

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: pynwb.validate can not check with NWBZarrIO

2 participants