Skip to content

zarr-format v2 stores written by zarr-python v3 can no longer be opened by zarr-python v2 due to a numcodecs TypeError #3016

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Metamess opened this issue Apr 24, 2025 · 1 comment
Labels
bug Potential issues with the zarr-python library

Comments

@Metamess
Copy link

Zarr version

v2.18.3, v3.0.7

Numcodecs version

v0.13.1, v0.16.0

Python Version

3.10, 3.13

Operating System

Linux

Installation

pip

Description

When using the current versions of zarr-python (3.0.7) and numcodecs (0.16.0) to write a zarr-format 2 store, the resulting store can no longer be opened by the latest zarr-python v2 (2.18.3) and numcodecs 0.13.1

Since zarr-developers/numcodecs#713, when writing the zarr, "compressor" section of the metadata will include the key "typesize", which will be passed to the init() of the compressor class, though this argument was not present at the time of zarr v2. The result is a TypeError when the zarr-python-2.18.3 tries to read the zarr-v2 store written by zarr-python-3.0.7.

Specifically, these old versions of zarr-python and numcodecs are the last releases to support python 3.10, meaning that for any project that has not been able to upgrade to a newer python version will not be able to open new zarr-v2 stores.

I am aware that support for Python3.10 is dropped in line with SPEC0, but I assume that the point of still supporting the creation of zarr-format-v2 stores would be to be backwards-compatible to the point that they can indeed be opened by the zarr-python-v2 library. Since this is now no longer the case, I chose to report this issue.

Steps to reproduce

With zarr==3.0.7 and numcodecs==0.16.0, create any zarr store. Then with zarr==2.18.3 and numcodecs==0.13.1, try to read that store.

Additional output

File ".venv/lib/python3.10/site-packages/xarray/backends/zarr.py", line 1103, in open_zarr
ds = open_dataset(
File ".venv/lib/python3.10/site-packages/xarray/backends/api.py", line 611, in open_dataset
backend_ds = backend.open_dataset(
File ".venv/lib/python3.10/site-packages/xarray/backends/zarr.py", line 1188, in open_dataset
ds = store_entrypoint.open_dataset(
File ".venv/lib/python3.10/site-packages/xarray/backends/store.py", line 43, in open_dataset
vars, attrs = filename_or_obj.load()
File ".venv/lib/python3.10/site-packages/xarray/backends/common.py", line 222, in load
(_decode_variable_name(k), v) for k, v in self.get_variables().items()
File ".venv/lib/python3.10/site-packages/xarray/backends/zarr.py", line 563, in get_variables
return FrozenDict(
File ".venv/lib/python3.10/site-packages/xarray/core/utils.py", line 416, in FrozenDict
return Frozen(dict(*args, **kwargs))
File ".venv/lib/python3.10/site-packages/xarray/backends/zarr.py", line 563, in
return FrozenDict(
File ".venv/lib/python3.10/site-packages/zarr/hierarchy.py", line 691, in _array_iter
yield _key if keys_only else (_key, self[key])
File ".venv/lib/python3.10/site-packages/zarr/hierarchy.py", line 467, in getitem
return Array(
File ".venv/lib/python3.10/site-packages/zarr/core.py", line 170, in init
self._load_metadata()
File ".venv/lib/python3.10/site-packages/zarr/core.py", line 193, in _load_metadata
self._load_metadata_nosync()
File ".venv/lib/python3.10/site-packages/zarr/core.py", line 240, in _load_metadata_nosync
self._compressor = get_codec(compressor)
File ".venv/lib/python3.10/site-packages/numcodecs/registry.py", line 51, in get_codec
return cls.from_config(config)
File ".venv/lib/python3.10/site-packages/numcodecs/abc.py", line 106, in from_config
return cls(**config)
File "numcodecs/blosc.pyx", line 548, in numcodecs.blosc.Blosc.init
TypeError: init() got an unexpected keyword argument 'typesize'

@Metamess Metamess added the bug Potential issues with the zarr-python library label Apr 24, 2025
@d-v-b
Copy link
Contributor

d-v-b commented Apr 24, 2025

thanks for this report @Metamess, this is a known issue stemming from the accidental release of a breaking change in numcodecs version 0.16. The next numcodecs release will revert this change (see this PR), so in the meantime I recommend avoiding numcodecs 0.16.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Potential issues with the zarr-python library
Projects
None yet
Development

No branches or pull requests

2 participants