-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
TypeError: Expected a BytesBytesCodec. Got <class 'numcodecs.blosc.Blosc'> instead. #10032
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
Comments
Thanks for opening your first issue here at xarray! Be sure to follow the issue template! |
Thanks for raising this @leoniewgnr ! We're still hunting down all the bugs that the move to zarr 3 created.
That's particularly weird - errors in the documentation examples are supposed to lead to errors in the CI... |
See also #9987 |
I think this example needs to be updated for zarr-python 3. Something like this works for me: diff --git a/doc/user-guide/io.rst b/doc/user-guide/io.rst
index 986d43ce..7f5d6e2b 100644
--- a/doc/user-guide/io.rst
+++ b/doc/user-guide/io.rst
@@ -829,10 +829,10 @@ For example:
:okwarning:
import zarr
- from numcodecs.blosc import Blosc
+ from zarr.codecs import BloscCodec
- compressor = Blosc(cname="zstd", clevel=3, shuffle=2)
- ds.to_zarr("foo.zarr", encoding={"foo": {"compressor": compressor}})
+ compressor = BloscCodec(cname="zstd", clevel=3, shuffle="shuffle")
+ ds.to_zarr("foo.zarr", encoding={"foo": {"compressors": (compressor,)}})
.. note:: (this is my best guess based on what I see in the backend tests some Zarr v3 related PRs. In this particular case, {"compressor": compressor} (without tuple) seems to also work.). Perhaps @d-v-b can confirm this is now the proper way to specify encoders/help with this? |
that looks right, although I'm not too familiar with what |
My situation with numcodecs 0.15.1 and Zarr 3.0.3 mirrors this: BytesBytesCodec is unavailable in numcodecs.abc, and even numcodecs.Blosc is rejected with TypeError: Expected a BytesBytesCodec. |
I'm running into this as well, even when using |
@FedeMPouzols, when I tried your suggested |
Didn't work for me either -- here's a reproducible example notebook: https://nbviewer.org/gist/rsignell/066cc39664a0c8b7fe70be1fd7d7e0cb |
Edited, because much simpler solution below.
|
Actually, the solution is a lot simpler, the codecs should be imported from
|
I also ran into this issue when trying to load zarr v2 Datatree and write a DataTree to a Zarr v3 store. As suggested, I tried using:
But this gave me the following warning:
May be I misunderstood something, but
Here’s what worked for me with Sentinel 1 sample data from EOPF Zarr sample service :
This worked for me with only warnings on consolidated metadata issue and produced a valid Zarr v3 store. Anyone has suggestions to avoid this messy re-write of encoding for datatree?? P.s I used P.P.s and thank you xarray developers to make datatree works with zarr3!! |
This code runs without any problems with zarr2, but give the following error when running with zarr3:
The error message is:
TypeError: Expected a BytesBytesCodec. Got <class 'numcodecs.blosc.Blosc'> instead.
The same error occurs in the documentation: https://docs.xarray.dev/en/stable/user-guide/io.html#zarr-compressors-and-filters
The text was updated successfully, but these errors were encountered: