-
-
Notifications
You must be signed in to change notification settings - Fork 331
Broken fill_value
encoding in consolidated_metadata
when writing format v2 from zarr-python 3
#2979
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
A datapoint here is that if you base64 decode the on disk value In [1]: import base64
In [2]: base64.b64decode("QQ==")
Out[2]: b'A' |
I'm not planing on looking into this further but putting down here the notes from debugging. The incorrect encoding happens in the zarr-python/src/zarr/abc/metadata.py Lines 18 to 37 in 5f49d24
with the issue being that the bytes were falling into the diff --git a/src/zarr/abc/metadata.py b/src/zarr/abc/metadata.py
index a56f9866..64ed6f4d 100644
--- a/src/zarr/abc/metadata.py
+++ b/src/zarr/abc/metadata.py
@@ -28,7 +28,7 @@ class Metadata:
value = getattr(self, key)
if isinstance(value, Metadata):
out_dict[field.name] = getattr(self, field.name).to_dict()
- elif isinstance(value, str):
+ elif isinstance(value, str | bytes):
out_dict[key] = value
elif isinstance(value, Sequence):
out_dict[key] = tuple(v.to_dict() if isinstance(v, Metadata) else v for v in value) but then there is an error in this block: zarr-python/src/zarr/core/group.py Lines 372 to 376 in 5f49d24
when ther ../../../miniforge3/lib/python3.12/json/encoder.py:439: in _iterencode
diff --git a/src/zarr/core/group.py b/src/zarr/core/group.py
index da2aa5f7..26a1c0db 100644
--- a/src/zarr/core/group.py
+++ b/src/zarr/core/group.py
@@ -369,6 +369,12 @@ class GroupMetadata(Metadata):
},
}
+ if "fill_value" in v:
+ from zarr.core.metadata.v2 import _serialize_fill_value
+
+ d[f"{k}/{ZARRAY_JSON}"]["fill_value"] = _serialize_fill_value(
+ v["fill_value"], np.dtype(v["dtype"])
+ )
items[ZMETADATA_V2_JSON] = prototype.buffer.from_bytes(
json.dumps(
{"metadata": d, "zarr_consolidated_format": 1}, |
I think this will be fixed by #2874 |
Zarr version
3.0.7.dev8+g018f61d9
Numcodecs version
0.15.1
Python Version
3.12
Operating System
mac
Installation
from source
Description
I think this is similar to #2741 but for consolidated metadata. Namely that
bytes
asfill_value
for zarr format 2 aren't properly encoded/decoded in consolidated metadata.Steps to reproduce
outputs:
Additional output
No response
The text was updated successfully, but these errors were encountered: