spatialdata icon indicating copy to clipboard operation
spatialdata copied to clipboard

Spatialdata object created from remote .zarr store does not preserve "path" property

Open adkinsrs opened this issue 11 months ago • 0 comments

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

adkinsrs avatar Feb 14 '25 15:02 adkinsrs