Skip to content

Introduce DaskReader with ts.virtual_chunked; unify get_tensorstore() API#2

Open
mkitti wants to merge 1 commit intoJaneliaSciComp:unifiedfrom
mkitti:mkitti-tensorstore-direct
Open

Introduce DaskReader with ts.virtual_chunked; unify get_tensorstore() API#2
mkitti wants to merge 1 commit intoJaneliaSciComp:unifiedfrom
mkitti:mkitti-tensorstore-direct

Conversation

@mkitti
Copy link
Contributor

@mkitti mkitti commented Mar 3, 2026

All readers now expose get_tensorstore() -> ts.TensorStore instead of
get_tensorstore_spec() -> dict.

  • Add DaskReader(BaseReader) intermediate class in readers/base.py:
    wraps dask arrays via ts.virtual_chunked with a synchronous _read_fn
    callback dispatched on TensorStore's thread pool. Chunk layout is
    aligned to the dask array's native chunk shape.
  • Tier 1 readers (N5, Zarr2, Zarr3, Precomputed): rename method and
    call ts.open() internally, returning an opened ts.TensorStore.
  • Tier 2 readers (TIFF, ND2, IMS, HDF5, CZI) and Tier 3 (BIOIOReader):
    extend DaskReader; remove sentinel {'driver': 'array', 'array': ...}
    dicts that were never opened with ts.open().
  • Converter: remove _is_tier2 branching and _domain_to_slices(); call
    reader.get_tensorstore() uniformly for all formats.
  • api/dataset.py, main.py: update all call sites accordingly.
  • Tests: replace get_tensorstore_spec() assertions with
    store.spec().to_json()['driver'] checks for Tier 1, and
    store[...].read().result() data access for all tiers.

Co-Authored-By: Claude Sonnet 4.6 [email protected]

… API

All readers now expose get_tensorstore() -> ts.TensorStore instead of
get_tensorstore_spec() -> dict.

- Add DaskReader(BaseReader) intermediate class in readers/base.py:
  wraps dask arrays via ts.virtual_chunked with a synchronous _read_fn
  callback dispatched on TensorStore's thread pool. Chunk layout is
  aligned to the dask array's native chunk shape.
- Tier 1 readers (N5, Zarr2, Zarr3, Precomputed): rename method and
  call ts.open() internally, returning an opened ts.TensorStore.
- Tier 2 readers (TIFF, ND2, IMS, HDF5, CZI) and Tier 3 (BIOIOReader):
  extend DaskReader; remove sentinel {'driver': 'array', 'array': ...}
  dicts that were never opened with ts.open().
- Converter: remove _is_tier2 branching and _domain_to_slices(); call
  reader.get_tensorstore() uniformly for all formats.
- api/dataset.py, __main__.py: update all call sites accordingly.
- Tests: replace get_tensorstore_spec() assertions with
  store.spec().to_json()['driver'] checks for Tier 1, and
  store[...].read().result() data access for all tiers.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
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.

1 participant