Skip to content

Tell what an asset is with is_nwb, is_bids and is_ome_zarr - #2009

Draft
CodyCBakerPhD wants to merge 3 commits into
claude/zarr-depth-chunk-keysfrom
claude/asset-kind-predicates
Draft

CodyCBakerPhD wants to merge 3 commits into
claude/zarr-depth-chunk-keysfrom
claude/asset-kind-predicates

Conversation

@CodyCBakerPhD

@CodyCBakerPhD CodyCBakerPhD commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

A refactoring split out of #1996, with no change in behaviour, so that #1996 can handle NWB files stored as Zarr by asking what an asset is, rather than adding another subclass.

All three are properties of LocalAsset, false unless a subclass which knows better says otherwise, so any asset can be asked any of them:

  • is_nwb: the asset is an NWB file: an NWBAsset, or a ZarrAsset named *.nwb.zarr.
  • is_bids: the asset is part of a BIDS dataset: the BIDS classes.
  • is_ome_zarr: the asset is an OME-Zarr: a ZarrAsset named *.ome.zarr.

They replace the suffix checks, and the isinstance(self, NWBBIDSAsset) check, spread over the asset classes. Code can thus ask what an asset is without knowing which of the classes combining storage and format it is an instance of.

NWBAsset.get_metadata() and NWBAsset.get_validation_errors() now take any LocalAsset as self, so that other assets which are NWB files can call them, as NWBBIDSAsset already does. #1996's ZarrAsset does so for *.nwb.zarr.

Stacked on #2008.


Generated by Claude Code

@CodyCBakerPhD CodyCBakerPhD added the internal Changes only affect the internal API label Dec 2, 2026 — with Claude
@codecov

codecov Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.38%. Comparing base (0a5a023) to head (5c45416).

Additional details and impacted files
@@                       Coverage Diff                        @@
##           claude/zarr-depth-chunk-keys    #2009      +/-   ##
================================================================
+ Coverage                         91.36%   91.38%   +0.01%     
================================================================
  Files                                99       99              
  Lines                             15919    15954      +35     
================================================================
+ Hits                              14545    14580      +35     
  Misses                             1374     1374              
Flag Coverage Δ
unittests 91.38% <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.

@CodyCBakerPhD
CodyCBakerPhD added this pull request to stack #2011 December 2, 2026 21:01
@CodyCBakerPhD CodyCBakerPhD self-assigned this Dec 2, 2026
LocalAsset.is_nwb (an NWB file, *.nwb, or *.nwb.zarr when stored as Zarr),
LocalAsset.is_bids (part of a BIDS dataset) and ZarrAsset.is_ome_zarr
replace the suffix checks, and the isinstance() check on NWBBIDSAsset,
scattered over the asset classes.  Code can thus ask what an asset is
without knowing which of the classes combining storage and format it is an
instance of.

NWBAsset.get_metadata() and NWBAsset.get_validation_errors() take any
LocalAsset as self (calling LocalAsset.get_validation_errors() rather than
super()'s), so that other assets which are NWB files, such as ZarrAsset for
NWB files stored as Zarr, can use them, as NWBBIDSAsset does.

No change in behaviour.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DQrzw5ecrJY9QseLyohB4j
@CodyCBakerPhD
CodyCBakerPhD force-pushed the claude/asset-kind-predicates branch from 8edb6d4 to 511a4f4 Compare December 4, 2026 16:23
is_nwb, is_bids and is_ome_zarr are now all properties of LocalAsset,
returning False, which the classes knowing better override: NWBAsset
(is_nwb), ZarrAsset (is_nwb and is_ome_zarr, by name) and the BIDS classes
(is_bids).  Any asset can thus be asked any of them, and each answer lives
in the class which knows it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DQrzw5ecrJY9QseLyohB4j
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.

2 participants