-
-
Notifications
You must be signed in to change notification settings - Fork 350
Open
Labels
bugPotential issues with the zarr-python libraryPotential issues with the zarr-python library
Description
Zarr version
'3.0.3.dev9+g90cc08d4.d20250206'
Numcodecs version
'0.15.0'
Python Version
3.13
Operating System
Mac
Installation
Description
Writing an array to FsspecStore containing a AsyncFileSystemWrapper object does not currently work.
Steps to reproduce
import zarr
from zarr.storage import FsspecStore
from fsspec.implementations.asyn_wrapper import AsyncFileSystemWrapper
import tempfile
import numpy as np
with tempfile.TemporaryDirectory() as tmp_path:
store = FsspecStore.from_url(f"local://{tmp_path}")
assert isinstance(store.fs, AsyncFileSystemWrapper)
assert store.fs.async_impl
z = zarr.create_array(
store=store,
shape=(100, 100),
chunks=(10, 10),
dtype="f4"
)
# write to the array
z[:, :] = np.random.random((100, 100))
Additional output
I added some print statements to check that the mode is correct for all the fsspec opener functions, which is consistently 'wb'. Here's the full traceback excluding those print statements:
File "/Users/max/Documents/Code/zarr-developers/zarr-python/.vscode/test-async-wrapper.py", line 18, in <module>
z[:, :] = np.random.random((100, 100))
~^^^^^^
File "/Users/max/Documents/Code/zarr-developers/zarr-python/src/zarr/core/array.py", line 2523, in __setitem__
self.set_orthogonal_selection(pure_selection, value, fields=fields)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/max/Documents/Code/zarr-developers/zarr-python/src/zarr/_compat.py", line 43, in inner_f
return f(*args, **kwargs)
File "/Users/max/Documents/Code/zarr-developers/zarr-python/src/zarr/core/array.py", line 2979, in set_orthogonal_selection
return sync(
self._async_array._set_selection(indexer, value, fields=fields, prototype=prototype)
)
File "/Users/max/Documents/Code/zarr-developers/zarr-python/src/zarr/core/sync.py", line 142, in sync
raise return_result
File "/Users/max/Documents/Code/zarr-developers/zarr-python/src/zarr/core/sync.py", line 98, in _runner
return await coro
^^^^^^^^^^
File "/Users/max/Documents/Code/zarr-developers/zarr-python/src/zarr/core/array.py", line 1413, in _set_selection
await self.codec_pipeline.write(
...<11 lines>...
)
File "/Users/max/Documents/Code/zarr-developers/zarr-python/src/zarr/core/codec_pipeline.py", line 468, in write
await concurrent_map(
...<6 lines>...
)
File "/Users/max/Documents/Code/zarr-developers/zarr-python/src/zarr/core/common.py", line 68, in concurrent_map
return await asyncio.gather(*[asyncio.ensure_future(run(item)) for item in items])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/max/Documents/Code/zarr-developers/zarr-python/src/zarr/core/common.py", line 66, in run
return await func(*item)
^^^^^^^^^^^^^^^^^
File "/Users/max/Documents/Code/zarr-developers/zarr-python/src/zarr/core/codec_pipeline.py", line 418, in write_batch
await concurrent_map(
...<8 lines>...
)
File "/Users/max/Documents/Code/zarr-developers/zarr-python/src/zarr/core/common.py", line 68, in concurrent_map
return await asyncio.gather(*[asyncio.ensure_future(run(item)) for item in items])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/max/Documents/Code/zarr-developers/zarr-python/src/zarr/core/common.py", line 66, in run
return await func(*item)
^^^^^^^^^^^^^^^^^
File "/Users/max/Documents/Code/zarr-developers/zarr-python/src/zarr/core/codec_pipeline.py", line 416, in _write_key
await byte_setter.set(chunk_bytes)
File "/Users/max/Documents/Code/zarr-developers/zarr-python/src/zarr/storage/_common.py", line 144, in set
await self.store.set(self.path, value)
File "/Users/max/Documents/Code/zarr-developers/zarr-python/src/zarr/storage/_fsspec.py", line 276, in set
await self.fs._pipe_file(path, value.to_bytes())
File "/Users/max/Library/Application Support/hatch/env/virtual/zarr/M9h0Qn3b/test.py3.13-2.1-optional/lib/python3.13/site-packages/fsspec/implementations/asyn_wrapper.py", line 27, in wrapper
return await asyncio.to_thread(func, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/max/miniforge3/envs/zarr-python-tests/lib/python3.13/asyncio/threads.py", line 25, in to_thread
return await loop.run_in_executor(None, func_call)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/max/miniforge3/envs/zarr-python-tests/lib/python3.13/concurrent/futures/thread.py", line 59, in run
result = self.fn(*self.args, **self.kwargs)
File "/Users/max/Library/Application Support/hatch/env/virtual/zarr/M9h0Qn3b/test.py3.13-2.1-optional/lib/python3.13/site-packages/fsspec/spec.py", line 787, in pipe_file
with self.open(path, "wb", **kwargs) as f:
~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
File "/Users/max/Library/Application Support/hatch/env/virtual/zarr/M9h0Qn3b/test.py3.13-2.1-optional/lib/python3.13/site-packages/fsspec/spec.py", line 1310, in open
f = self._open(
path,
...<4 lines>...
**kwargs,
)
File "/Users/max/Library/Application Support/hatch/env/virtual/zarr/M9h0Qn3b/test.py3.13-2.1-optional/lib/python3.13/site-packages/fsspec/implementations/local.py", line 200, in _open
return LocalFileOpener(path, mode, fs=self, **kwargs)
File "/Users/max/Library/Application Support/hatch/env/virtual/zarr/M9h0Qn3b/test.py3.13-2.1-optional/lib/python3.13/site-packages/fsspec/implementations/local.py", line 364, in __init__
self._open()
~~~~~~~~~~^^
File "/Users/max/Library/Application Support/hatch/env/virtual/zarr/M9h0Qn3b/test.py3.13-2.1-optional/lib/python3.13/site-packages/fsspec/implementations/local.py", line 369, in _open
self.f = open(self.path, mode=self.mode)
~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/var/folders/70/hc_nynms54d8lp67z4rsfctc0000gp/T/tmpjmu3h688/c/0/2'
Metadata
Metadata
Assignees
Labels
bugPotential issues with the zarr-python libraryPotential issues with the zarr-python library