You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At least for MemoryStore. The group.__getitem__ eventually tries to do a MemoryStore.get. The store is closed (by the user) and so it attempts to reopen. For MemoryStore, that doesn't really matter but since we have mode="w" the dict is cleared and the lookup failed.
Steps to reproduce
In [1]: importzarrIn [2]: store=zarr.storage.MemoryStore({}, mode="w")
In [3]: group=zarr.group(store=store)
In [4]: group.create(name="a", shape=(5,))
Out[4]: <Arraymemory://4441054784/ashape=(5,) dtype=float64>In [5]: store.close()
In [6]: group["a"]
---------------------------------------------------------------------------KeyErrorTraceback (mostrecentcalllast)
CellIn[6], line1---->1group["a"]
File~/gh/zarr-developers/zarr-python/src/zarr/core/group.py:1327, inGroup.__getitem__(self, path)
1326def__getitem__(self, path: str) ->Array|Group:
->1327obj=self._sync(self._async_group.getitem(path))
1328ifisinstance(obj, AsyncArray):
1329returnArray(obj)
File~/gh/zarr-developers/zarr-python/src/zarr/core/sync.py:185, inSyncMixin._sync(self, coroutine)
182def_sync(self, coroutine: Coroutine[Any, Any, T]) ->T:
183# TODO: refactor this to to take *args and **kwargs and pass those to the method184# this should allow us to better type the sync wrapper-->185returnsync(
186coroutine,
187timeout=config.get("async.timeout"),
188 )
File~/gh/zarr-developers/zarr-python/src/zarr/core/sync.py:141, insync(coro, loop, timeout)
138return_result=next(iter(finished)).result()
140ifisinstance(return_result, BaseException):
-->141raisereturn_result142else:
143returnreturn_resultFile~/gh/zarr-developers/zarr-python/src/zarr/core/sync.py:100, in_runner(coro)
95""" 96 Await a coroutine and return the result of running it. If awaiting the coroutine raises an 97 exception, the exception will be returned. 98 """99try:
-->100returnawaitcoro101exceptExceptionasex:
102returnexFile~/gh/zarr-developers/zarr-python/src/zarr/core/group.py:617, inAsyncGroup.getitem(self, key)
615zarr_json_bytes=await (store_path/ZARR_JSON).get()
616ifzarr_json_bytesisNone:
-->617raiseKeyError(key)
618else:
619zarr_json=json.loads(zarr_json_bytes.to_bytes())
KeyError: 'a'
In zarr-python 2.x, no error is raised:
In [1]: importzarrIn [2]: store=zarr.storage.KVStore({})
In [3]: group=zarr.group(store=store)
In [4]: group.create(name="a", shape=(5,))
Out[4]: <zarr.core.Array'/a' (5,) float64>In [6]: store.close()
In [7]: group["a"]
Out[7]: <zarr.core.Array'/a' (5,) float64>
Additional output
No response
The text was updated successfully, but these errors were encountered:
Zarr version
v3
Numcodecs version
na
Python Version
na
Operating System
na
Installation
na
Description
v3's behavior differs when you
At least for MemoryStore. The
group.__getitem__
eventually tries to do aMemoryStore.get
. The store is closed (by the user) and so it attempts to reopen. For MemoryStore, that doesn't really matter but since we havemode="w"
the dict is cleared and the lookup failed.Steps to reproduce
In zarr-python 2.x, no error is raised:
Additional output
No response
The text was updated successfully, but these errors were encountered: