Closed
Description
Zarr version
3.0.0a0
Numcodecs version
0.12.1
Python Version
3.10.12
Operating System
Linux
Installation
pip install zarr==3.0.0a0
Description
This is a downstream issue for Kerchunk.
In ZarrV2, BaseStore
inherited from MutableMapping
which brought with it the ability to copy()
and call items()
on a BaseStore
, which Kerchunk depended on here.
In ZarrV3, neither StorePath
nor Store
are copy()
-able, and of course __iter__
, __setitem__
, and __getitem__
are not available to make it anything like a MutableMapping
.
@martindurant do you think this is something Kerchunk should handle or should ZarrV3 preserve the behavior of stores?
Steps to reproduce
This is the definition of the function Kerchunk is calling:
from zarr.store.core import MemoryStore, StorePath
def _encode_for_JSON(store):
"""Make store JSON encodable"""
for k, v in store.copy().items():
if isinstance(v, list):
continue
else:
try:
# minify JSON
v = ujson.dumps(ujson.loads(v))
except (ValueError, TypeError):
pass
try:
store[k] = v.decode() if isinstance(v, bytes) else v
except UnicodeDecodeError:
store[k] = "base64:" + base64.b64encode(v).decode()
return store
_encode_for_JSON(StorePath(MemoryStore(mode="w"))) # Will throw
Additional output
No response