ome / ome-zarr-py

Implementation of next-generation file format (NGFF) specifications for storing bioimaging data in the cloud.
https://pypi.org/project/ome-zarr
Other
156 stars 54 forks source link

write_image fails with fsspec 2023.9.0 #305

Closed joshua-gould closed 1 year ago

joshua-gould commented 1 year ago
import numpy as np
import zarr
import os

from ome_zarr.io import parse_url
from ome_zarr.writer import write_image

path = "test_ngff_image.zarr"
os.mkdir(path)

store = parse_url(path, mode="w").store
root = zarr.group(store=store)
mean_val=10
size_xy = 128
size_z = 10
rng = np.random.default_rng(0)
data = rng.poisson(mean_val, size=(size_z, size_xy, size_xy)).astype(np.uint8)
write_image(image=data, group=root, axes="zyx")

Traceback (most recent call last):
  File "<ipython-input-2-96918b6cb47f>", line 18, in <module>
    write_image(image=data, group=root, axes="zyx")
  File "lib/python3.10/site-packages/ome_zarr/writer.py", line 492, in write_image
    dask_delayed_jobs = write_multiscale(
  File "lib/python3.10/site-packages/ome_zarr/writer.py", line 266, in write_multiscale
    group.create_dataset(str(path), data=data, chunks=chunks_opt, **options)
  File "lib/python3.10/site-packages/zarr/hierarchy.py", line 1094, in create_dataset
    return self._write_op(self._create_dataset_nosync, name, **kwargs)
  File "lib/python3.10/site-packages/zarr/hierarchy.py", line 935, in _write_op
    return f(*args, **kwargs)
  File "lib/python3.10/site-packages/zarr/hierarchy.py", line 1110, in _create_dataset_nosync
    a = array(data, store=self._store, path=path, chunk_store=self._chunk_store, **kwargs)
  File "lib/python3.10/site-packages/zarr/creation.py", line 439, in array
    z[...] = data
  File "lib/python3.10/site-packages/zarr/core.py", line 1497, in __setitem__
    self.set_basic_selection(pure_selection, value, fields=fields)
  File "lib/python3.10/site-packages/zarr/core.py", line 1593, in set_basic_selection
    return self._set_basic_selection_nd(selection, value, fields=fields)
  File "lib/python3.10/site-packages/zarr/core.py", line 1983, in _set_basic_selection_nd
    self._set_selection(indexer, value, fields=fields)
  File "lib/python3.10/site-packages/zarr/core.py", line 2058, in _set_selection
    self._chunk_setitems(lchunk_coords, lchunk_selection, chunk_values, fields=fields)
  File "lib/python3.10/site-packages/zarr/core.py", line 2261, in _chunk_setitems
    self.chunk_store.setitems(to_store)
  File "lib/python3.10/site-packages/zarr/storage.py", line 1441, in setitems
    self.map.setitems(values)
  File "lib/python3.10/site-packages/fsspec/mapping.py", line 124, in setitems
    self.fs.pipe(values)
  File "lib/python3.10/site-packages/fsspec/spec.py", line 824, in pipe
    self.pipe_file(self._strip_protocol(k), v, **kwargs)
  File "lib/python3.10/site-packages/fsspec/spec.py", line 803, in pipe_file
    with self.open(path, "wb", **kwargs) as f:
  File "lib/python3.10/site-packages/fsspec/spec.py", line 1309, in open
    f = self._open(
  File "lib/python3.10/site-packages/fsspec/implementations/local.py", line 180, in _open
    return LocalFileOpener(path, mode, fs=self, **kwargs)
  File "lib/python3.10/site-packages/fsspec/implementations/local.py", line 298, in __init__
    self._open()
  File "lib/python3.10/site-packages/fsspec/implementations/local.py", line 303, in _open
    self.f = open(self.path, mode=self.mode)
FileNotFoundError: [Errno 2] No such file or directory: 'test_ngff_image.zarr/0/0/0/0'
will-moore commented 1 year ago

Thanks for the feedback. This is a duplicate of issue #304, so please refer to that issue (and I'll close this one)...