xarray-tensorstore
raw JSON → 0.3.0 verified Sat May 09 auth: no python
Provides xarray backends for reading and writing N-dimensional arrays via TensorStore, enabling distributed and chunked access to Zarr, N5, and other stores. Current version: 0.3.0, release cadence: irregular.
pip install xarray-tensorstore Common errors
error ValueError: unrecognized backend 'tensorstore'. Must be one of: ... ↓
cause xarray-tensorstore is not installed or the import hook didn't register the backend.
fix
Install xarray-tensorstore: pip install xarray-tensorstore. Then import xarray before using the backend.
error ModuleNotFoundError: No module named 'xarray.contrib.tensorstore' ↓
cause Import path changed in version 0.3.0.
fix
Use 'from xarray.tensorstore import TensorStoreBackend' instead.
error TypeError: open_zarr() got an unexpected keyword argument 'tensorstore_kwargs' ↓
cause tensorstore_kwargs was removed in version 0.3.0.
fix
Use backend_kwargs parameter: xr.open_zarr(..., backend='tensorstore', backend_kwargs={'open': {'k1': 'v1'}})
Warnings
gotcha The tensorstore backend requires explicit specification via 'backend' keyword. Without it, xarray defaults to zarr-python backend. ↓
fix Always include backend='tensorstore' in open_zarr() or to_zarr() calls.
breaking In version 0.3.0, the import path changed from xarray.contrib.tensorstore to xarray.tensorstore. Existing code using the old import will break. ↓
fix Use 'from xarray.tensorstore import TensorStoreBackend' instead of 'from xarray.contrib.tensorstore import ...'
deprecated The 'tensorstore_kwargs' argument in open_zarr is deprecated in favor of passing kwargs via 'backend_kwargs'. ↓
fix Use backend_kwargs={'open': {...}} instead of tensorstore_kwargs={'open': {...}}
Imports
- tensorstore_backend wrong
from xarray.backends import TensorStoreBackendcorrectfrom xarray.tensorstore import TensorStoreBackend
Quickstart
import xarray as xr
import os
# Open a TensorStore-backed Zarr store
store_url = '/tmp/test.zarr'
ds = xr.open_zarr(store_url, backend='tensorstore')
print(ds)
# Write with TensorStore backend
ds = xr.Dataset({'var': (('x',), [1,2,3])})
ds.to_zarr(store_url, backend='tensorstore')