ome-zarr-py icon indicating copy to clipboard operation
ome-zarr-py copied to clipboard

Cannot overwrite Zarr opened with `mode= "a"`

Open chourroutm opened this issue 9 months ago • 3 comments

To my understanding, zarr supports rewriting with the mode= "a". However, it is not supported by ome-zarr-py.

Example code

import zarr
import ome_zarr.io, ome_zarr.writer

vol = np.zeros((512,512,512))
store = ome_zarr.io.parse_url("all_zeros.ome.zarr",mode="a").store
root = zarr.group(store=store)
ome_zarr.writer.write_image(image=vol, group=root, axes="zyx",chunks=128)

store2 = ome_zarr.io.parse_url("all_zeros.ome.zarr",mode="a").store
root2 = zarr.group(store=store2)
ome_zarr.writer.write_image(image=vol, group=root2, axes="zyx",chunks=128)

What I expect

To be able to overwrite the file all_zeros.ome.zarr when I specify mode= "a".

What I get

ContainsArrayError Traceback (most recent call last) Cell In[10], line 8 6 store2 = ome_zarr.io.parse_url("all_zeros.ome.zarr",mode="a").store 7 root2 = zarr.group(store=store2) ----> 8 ome_zarr.writer.write_image(image=vol, group=root2, axes="zyx",chunks=128)

[...]

File .venv\Lib\site-packages\zarr\storage.py:523, in _init_array_metadata(store, shape, chunks, dtype, compressor, fill_value, order, overwrite, path, chunk_store, filters, object_codec, dimension_separator, storage_transformers) 521 if not overwrite: 522 if contains_array(store, path): --> 523 raise ContainsArrayError(path) 524 elif contains_group(store, path, explicit_only=False): 525 raise ContainsGroupError(path)

ContainsArrayError: path '0' contains an array"

(Error log: full_error.txt)

chourroutm avatar May 07 '24 14:05 chourroutm