Skip to content

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

Open
h-mayorquin wants to merge 1 commit into
devfrom
fix_zarr_validate
Open

Fix pynwb.validate() for Zarr-backed NWB files#2187
h-mayorquin wants to merge 1 commit 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
Copy link
Copy Markdown

codecov Bot commented May 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.19%. Comparing base (9231882) to head (db00200).

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #2187      +/-   ##
==========================================
+ Coverage   95.18%   95.19%   +0.01%     
==========================================
  Files          30       30              
  Lines        2991     2999       +8     
  Branches      444      445       +1     
==========================================
+ Hits         2847     2855       +8     
  Misses         86       86              
  Partials       58       58              
Flag Coverage Δ
integration 73.12% <100.00%> (+0.07%) ⬆️
unit 85.66% <95.23%> (+0.07%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 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

1 participant