Spatialdata object created from remote .zarr store does not preserve "path" property
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 394
- Forks
- 95
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 7
Description
Local representation of the SpatialData object when read in locally. This is a Visium HD dataset that I created originally using spatialdata_io.visium_hd + some post-processing stuff.
SpatialData object, with associated Zarr store: /<path>/11692b64-b34a-4dbe-adc9-784a87a7a856.zarr
├── Images
│ ├── 'spatialdata_hires_image': DataArray[cyx] (3, 4352, 6000)
│ └── 'spatialdata_lowres_image': DataArray[cyx] (3, 435, 600)
├── Shapes
│ └── 'spatialdata_square_008um': GeoDataFrame shape: (127839, 1) (2D shapes)
└── Tables
├── 'square_008um': AnnData (127839, 19059)
└── 'table': AnnData (127839, 19059)
with coordinate systems:
▸ 'downscaled_hires', with elements:
spatialdata_hires_image (Images), spatialdata_square_008um (Shapes)
▸ 'downscaled_lowres', with elements:
spatialdata_lowres_image (Images), spatialdata_square_008um (Shapes)
▸ 'global', with elements:
spatialdata_square_008um (Shapes)
Recommendation: attach a minimal working example
Generally, the easier it is for us to reproduce the issue, the faster we can work on it. It is not required, but if you can, please:
Reproducible example
This is a public dataset and the datastore should be downloadable
import spatialdata as sd
rem_path = "https://devel.umgear.org/datasets/spatial/11692b64-b34a-4dbe-adc9-784a87a7a856.zarr"
sdata = sd.read_zarr(rem_path, selection=["images", "tables"])
print(sdata)
# ERROR
Describe the bug
This isn't the largest issue as I do not see a real-world situation were I have to print "sdata" outside of debugging but I'm sure this issue would have downstream effects elsewhere. It seems that the "path" property of the SpatialData object is not created.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/homebrew/lib/python3.12/site-packages/spatialdata/_core/spatialdata.py", line 1971, in __repr__
return self._gen_repr()
^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.12/site-packages/spatialdata/_core/spatialdata.py", line 2121, in _gen_repr
elements_only_in_sdata, elements_only_in_zarr = self._symmetric_difference_with_zarr_store()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.12/site-packages/spatialdata/_core/spatialdata.py", line 1105, in _symmetric_difference_with_zarr_store
elements_in_zarr = self.elements_paths_on_disk()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.12/site-packages/spatialdata/_core/spatialdata.py", line 1073, in elements_paths_on_disk
store = parse_url(self.path, mode="r").store
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'store'
Expected behavior
The SpatialData object is printed much like the local representation
Desktop (optional):
- Tested in MacOS Sequoia 15.3 as well as a Dockerized Ubuntu:jammy image
Additional context
Relevant package versions. If you need me to go into a deeper dive, let me know
Python 3.12.7
spatialdata==0.3.0
spatialdata_io==0.1.6
pandas==2.2.1
anndata==0.10.6
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with spatialdata/_core/spatialdata.py, especially read_zarr, repr, _gen_repr, _symmetric_difference_with_zarr_store, and elements_paths_on_disk. Reproduce the failure with the remote URL and selection=["images", "tables"]. Done means printing the remotely read SpatialData object succeeds and matches the expected local-style representation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100