from spatialdata.datasets import blobs
sdata = blobs()
sdata.write("/Volumes/Extreme SSD/P26_BCCN/blobs.zarr")
Blobs traceback
```python
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
Cell In[50], line 1
----> 1 sdata.write("/Volumes/Extreme SSD/P26_BCCN/blobs.zarr")
File /opt/homebrew/Caskroom/mambaforge/base/envs/spatialdata/lib/python3.10/site-packages/spatialdata/_core/spatialdata.py:1159, in SpatialData.write(self, file_path, overwrite, consolidate_metadata, format)
1156 store.close()
1158 for element_type, element_name, element in self.gen_elements():
-> 1159 self._write_element(
1160 element=element,
1161 zarr_container_path=file_path,
1162 element_type=element_type,
1163 element_name=element_name,
1164 overwrite=False,
1165 format=format,
1166 )
1168 if self.path != file_path:
1169 old_path = self.path
File /opt/homebrew/Caskroom/mambaforge/base/envs/spatialdata/lib/python3.10/site-packages/spatialdata/_core/spatialdata.py:1211, in SpatialData._write_element(self, element, zarr_container_path, element_type, element_name, overwrite, format)
1209 write_shapes(shapes=element, group=element_type_group, name=element_name, format=parsed["shapes"])
1210 elif element_type == "tables":
-> 1211 write_table(table=element, group=element_type_group, name=element_name, format=parsed["tables"])
1212 else:
1213 raise ValueError(f"Unknown element type: {element_type}")
File /opt/homebrew/Caskroom/mambaforge/base/envs/spatialdata/lib/python3.10/site-packages/spatialdata/_io/io_table.py:89, in write_table(table, group, name, group_type, format)
87 else:
88 region, region_key, instance_key = (None, None, None)
---> 89 write_adata(group, name, table) # creates group[name]
90 tables_group = group[name]
91 tables_group.attrs["spatialdata-encoding-type"] = group_type
File /opt/homebrew/Caskroom/mambaforge/base/envs/spatialdata/lib/python3.10/site-packages/anndata/_io/specs/registry.py:482, in write_elem(store, k, elem, dataset_kwargs)
458 def write_elem(
459 store: GroupStorageType,
460 k: str,
(...)
463 dataset_kwargs: Mapping[str, Any] = MappingProxyType({}),
464 ) -> None:
465 """
466 Write an element to a storage group using anndata encoding.
467
(...)
480 E.g. for zarr this would be `chunks`, `compressor`.
481 """
--> 482 Writer(_REGISTRY).write_elem(store, k, elem, dataset_kwargs=dataset_kwargs)
File /opt/homebrew/Caskroom/mambaforge/base/envs/spatialdata/lib/python3.10/site-packages/anndata/_io/utils.py:248, in report_write_key_on_error..func_wrapper(*args, **kwargs)
246 raise ValueError("No element found in args.")
247 try:
--> 248 return func(*args, **kwargs)
249 except Exception as e:
250 path = _get_display_path(store)
File /opt/homebrew/Caskroom/mambaforge/base/envs/spatialdata/lib/python3.10/site-packages/anndata/_io/specs/registry.py:350, in Writer.write_elem(self, store, k, elem, dataset_kwargs, modifiers)
348 store.clear()
349 elif k in store:
--> 350 del store[k]
352 write_func = self.find_write_func(dest_type, elem, modifiers)
354 if self.callback is None:
File /opt/homebrew/Caskroom/mambaforge/base/envs/spatialdata/lib/python3.10/site-packages/zarr/hierarchy.py:517, in Group.__delitem__(self, item)
516 def __delitem__(self, item):
--> 517 return self._write_op(self._delitem_nosync, item)
File /opt/homebrew/Caskroom/mambaforge/base/envs/spatialdata/lib/python3.10/site-packages/zarr/hierarchy.py:952, in Group._write_op(self, f, *args, **kwargs)
949 lock = self._synchronizer[group_meta_key]
951 with lock:
--> 952 return f(*args, **kwargs)
File /opt/homebrew/Caskroom/mambaforge/base/envs/spatialdata/lib/python3.10/site-packages/zarr/hierarchy.py:524, in Group._delitem_nosync(self, item)
520 path = self._item_path(item)
521 if contains_array(self._store, path) or contains_group(
522 self._store, path, explicit_only=False
523 ):
--> 524 rmdir(self._store, path)
525 else:
526 raise KeyError(item)
File /opt/homebrew/Caskroom/mambaforge/base/envs/spatialdata/lib/python3.10/site-packages/zarr/storage.py:212, in rmdir(store, path)
209 store_version = getattr(store, "_store_version", 2)
210 if hasattr(store, "rmdir") and store.is_erasable(): # type: ignore
211 # pass through
--> 212 store.rmdir(path)
213 else:
214 # slow version, delete one key at a time
215 if store_version == 2:
File /opt/homebrew/Caskroom/mambaforge/base/envs/spatialdata/lib/python3.10/site-packages/zarr/storage.py:1549, in FSStore.rmdir(self, path)
1547 store_path = self.dir_path(path)
1548 if self.fs.isdir(store_path):
-> 1549 self.fs.rm(store_path, recursive=True)
File /opt/homebrew/Caskroom/mambaforge/base/envs/spatialdata/lib/python3.10/site-packages/fsspec/implementations/local.py:172, in LocalFileSystem.rm(self, path, recursive, maxdepth)
170 if osp.abspath(p) == os.getcwd():
171 raise ValueError("Cannot delete current working directory")
--> 172 shutil.rmtree(p)
173 else:
174 os.remove(p)
File /opt/homebrew/Caskroom/mambaforge/base/envs/spatialdata/lib/python3.10/shutil.py:717, in rmtree(path, ignore_errors, onerror)
715 try:
716 if os.path.samestat(orig_st, os.fstat(fd)):
--> 717 _rmtree_safe_fd(fd, path, onerror)
718 try:
719 os.rmdir(path)
File /opt/homebrew/Caskroom/mambaforge/base/envs/spatialdata/lib/python3.10/shutil.py:674, in _rmtree_safe_fd(topfd, path, onerror)
672 os.unlink(entry.name, dir_fd=topfd)
673 except OSError:
--> 674 onerror(os.unlink, fullname, sys.exc_info())
File /opt/homebrew/Caskroom/mambaforge/base/envs/spatialdata/lib/python3.10/shutil.py:672, in _rmtree_safe_fd(topfd, path, onerror)
670 else:
671 try:
--> 672 os.unlink(entry.name, dir_fd=topfd)
673 except OSError:
674 onerror(os.unlink, fullname, sys.exc_info())
FileNotFoundError: [Errno 2] No such file or directory: '._.zgroup'
Error raised while writing key 'table' of to /tables
```
Describe the bug
I was incrementally creating a sdata with my data, parsed image, wrote it to SSD. Parsed and added Labels, wrote to SSD. Parsed and added anndata table, and trying write to SSD fails. this was replicated with blobs database.
Expected behavior
Writing the sdata to an external drive
I cannot write my sdata objects to SSD if they contain a table element
If I try to write sdata with table to external drive I get the following traceback:
Traceback
```python --------------------------------------------------------------------------- FileNotFoundError Traceback (most recent call last) Cell In[45], line 1 ----> 1 sdata.write(f"/Volumes/Extreme SSD/P26_BCCN/991_SpatialData_w_table.zarr") File /opt/homebrew/Caskroom/mambaforge/base/envs/spatialdata/lib/python3.10/site-packages/spatialdata/_core/spatialdata.py:1159, in SpatialData.write(self, file_path, overwrite, consolidate_metadata, format) 1156 store.close() 1158 for element_type, element_name, element in self.gen_elements(): -> 1159 self._write_element( 1160 element=element, 1161 zarr_container_path=file_path, 1162 element_type=element_type, 1163 element_name=element_name, 1164 overwrite=False, 1165 format=format, 1166 ) 1168 if self.path != file_path: 1169 old_path = self.path File /opt/homebrew/Caskroom/mambaforge/base/envs/spatialdata/lib/python3.10/site-packages/spatialdata/_core/spatialdata.py:1211, in SpatialData._write_element(self, element, zarr_container_path, element_type, element_name, overwrite, format) 1209 write_shapes(shapes=element, group=element_type_group, name=element_name, format=parsed["shapes"]) 1210 elif element_type == "tables": -> 1211 write_table(table=element, group=element_type_group, name=element_name, format=parsed["tables"]) 1212 else: 1213 raise ValueError(f"Unknown element type: {element_type}") File /opt/homebrew/Caskroom/mambaforge/base/envs/spatialdata/lib/python3.10/site-packages/spatialdata/_io/io_table.py:89, in write_table(table, group, name, group_type, format) 87 else: 88 region, region_key, instance_key = (None, None, None) ---> 89 write_adata(group, name, table) # creates group[name] 90 tables_group = group[name] 91 tables_group.attrs["spatialdata-encoding-type"] = group_type File /opt/homebrew/Caskroom/mambaforge/base/envs/spatialdata/lib/python3.10/site-packages/anndata/_io/specs/registry.py:482, in write_elem(store, k, elem, dataset_kwargs) 458 def write_elem( 459 store: GroupStorageType, 460 k: str, (...) 463 dataset_kwargs: Mapping[str, Any] = MappingProxyType({}), 464 ) -> None: 465 """ 466 Write an element to a storage group using anndata encoding. 467 (...) 480 E.g. for zarr this would be `chunks`, `compressor`. 481 """ --> 482 Writer(_REGISTRY).write_elem(store, k, elem, dataset_kwargs=dataset_kwargs) File /opt/homebrew/Caskroom/mambaforge/base/envs/spatialdata/lib/python3.10/site-packages/anndata/_io/utils.py:248, in report_write_key_on_error.Reproduce using the
blobs
datasetBlobs traceback
```python --------------------------------------------------------------------------- FileNotFoundError Traceback (most recent call last) Cell In[50], line 1 ----> 1 sdata.write("/Volumes/Extreme SSD/P26_BCCN/blobs.zarr") File /opt/homebrew/Caskroom/mambaforge/base/envs/spatialdata/lib/python3.10/site-packages/spatialdata/_core/spatialdata.py:1159, in SpatialData.write(self, file_path, overwrite, consolidate_metadata, format) 1156 store.close() 1158 for element_type, element_name, element in self.gen_elements(): -> 1159 self._write_element( 1160 element=element, 1161 zarr_container_path=file_path, 1162 element_type=element_type, 1163 element_name=element_name, 1164 overwrite=False, 1165 format=format, 1166 ) 1168 if self.path != file_path: 1169 old_path = self.path File /opt/homebrew/Caskroom/mambaforge/base/envs/spatialdata/lib/python3.10/site-packages/spatialdata/_core/spatialdata.py:1211, in SpatialData._write_element(self, element, zarr_container_path, element_type, element_name, overwrite, format) 1209 write_shapes(shapes=element, group=element_type_group, name=element_name, format=parsed["shapes"]) 1210 elif element_type == "tables": -> 1211 write_table(table=element, group=element_type_group, name=element_name, format=parsed["tables"]) 1212 else: 1213 raise ValueError(f"Unknown element type: {element_type}") File /opt/homebrew/Caskroom/mambaforge/base/envs/spatialdata/lib/python3.10/site-packages/spatialdata/_io/io_table.py:89, in write_table(table, group, name, group_type, format) 87 else: 88 region, region_key, instance_key = (None, None, None) ---> 89 write_adata(group, name, table) # creates group[name] 90 tables_group = group[name] 91 tables_group.attrs["spatialdata-encoding-type"] = group_type File /opt/homebrew/Caskroom/mambaforge/base/envs/spatialdata/lib/python3.10/site-packages/anndata/_io/specs/registry.py:482, in write_elem(store, k, elem, dataset_kwargs) 458 def write_elem( 459 store: GroupStorageType, 460 k: str, (...) 463 dataset_kwargs: Mapping[str, Any] = MappingProxyType({}), 464 ) -> None: 465 """ 466 Write an element to a storage group using anndata encoding. 467 (...) 480 E.g. for zarr this would be `chunks`, `compressor`. 481 """ --> 482 Writer(_REGISTRY).write_elem(store, k, elem, dataset_kwargs=dataset_kwargs) File /opt/homebrew/Caskroom/mambaforge/base/envs/spatialdata/lib/python3.10/site-packages/anndata/_io/utils.py:248, in report_write_key_on_error.Describe the bug I was incrementally creating a sdata with my data, parsed image, wrote it to SSD. Parsed and added Labels, wrote to SSD. Parsed and added anndata table, and trying write to SSD fails. this was replicated with blobs database.
Expected behavior Writing the sdata to an external drive
Mamba environment