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
ValueError Traceback (most recent call last)
in SpatialData.add_image(self, name, image, storage_options, overwrite)
659 target_path = os.path.realpath(os.path.join(self.path, "images", name))
660 if target_path in files:
--> 661 raise ValueError(
662 "Cannot add the image to the SpatialData object because it would overwrite an element that it is"
663 "using for backing. See more here: #138"
664 )
665 self._add_image_in_memory(name=name, image=image, overwrite=overwrite)
666 # old code to support overwriting the backing file
667 # with tempfile.TemporaryDirectory() as tmpdir:
668 # store = parse_url(Path(tmpdir) / "data.zarr", mode="w").store
(...)
692 # image = _read_multiscale(str(tgt_element_path), raster_type="image")
693 # self._add_image_in_memory(name=name, image=image, overwrite=True)
ValueError: Cannot add the image to the SpatialData object because it would overwrite an element that it isusing for backing. See more here: #138
However, if I do a persist(), I am allowed to overwrite:
When writing an image to zarr with overwrite=True, I found some unexpected behaviour.
Below I give a mimimal example to reproduce the issue.
This works, as expected. I can overwrite image layer 'image'.
However, when I add some processing (e.g. multiplying by two) before replacing sdata["image" ]:
I get the error:
However, if I do a persist(), I am allowed to overwrite:
And I am also allowed to do this (typical scenario where you want to do some processing twice with e.g. different parameters etc.):
The text was updated successfully, but these errors were encountered: