Skip to content

Cloud fix remote embl datasets #904

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: cloud
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions src/spatialdata/_io/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,12 +409,8 @@ def _open_zarr_store(path: StoreLike, **kwargs: Any) -> zarr.storage.BaseStore:
# but extend the path of the store with that of the zarr.Group
return FSStore(path.store.path + "/" + path.path, fs=path.store.fs, **kwargs)
if isinstance(path.store, zarr.storage.ConsolidatedMetadataStore):
# TODO: find a way to check if the consolidated metadata is still used. Probably best to wait for Zarr v3.
# if the store is a ConsolidatedMetadataStore, just return it
# get the FSStore url path from store and append it with the path from the Group StoreLike object
url = UPath(path.store.store.path + path.path)
# same as UPath option
return FSStore(url.path, fs=url.fs, **kwargs)
# if the store is a ConsolidatedMetadataStore, just return the underlying FSSpec store
return path.store.store
raise ValueError(f"Unsupported store type or zarr.Group: {type(path.store)}")
if isinstance(path, zarr.storage.StoreLike):
# if the input already a store, wrap it in an FSStore
Expand Down
2 changes: 1 addition & 1 deletion src/spatialdata/_io/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ def validate_table(
def format_implementations() -> Iterator[Format]:
"""Return an instance of each format implementation, newest to oldest."""
yield RasterFormatV02()
# yield RasterFormatV01() # same format string as FormatV04
yield RasterFormatV01() # same format string as FormatV04
yield FormatV04()
yield FormatV03()
yield FormatV02()
Expand Down
19 changes: 10 additions & 9 deletions tests/io/test_remote.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
import pytest
import zarr
from upath import UPath

from spatialdata import SpatialData


class TestRemote:
# Test actual remote datasets from https://spatialdata.scverse.org/en/latest/tutorials/notebooks/datasets/README.html
# TODO: mark these tests so they are disabled by default because they require internet access

@pytest.fixture(params=["merfish", "mibitof", "mibitof_alt"])
def s3_address(self, request):
urls = {
"merfish": "https://s3.embl.de/spatialdata/spatialdata-sandbox/merfish.zarr/",
"mibitof": "https://s3.embl.de/spatialdata/spatialdata-sandbox/mibitof.zarr/",
"merfish": UPath(
"s3://spatialdata/spatialdata-sandbox/merfish.zarr", endpoint_url="https://s3.embl.de", anon=True
),
"mibitof": UPath(
"s3://spatialdata/spatialdata-sandbox/mibitof.zarr", endpoint_url="https://s3.embl.de", anon=True
),
"mibitof_alt": "https://dl01.irc.ugent.be/spatial/mibitof/data.zarr/",
}
return urls[request.param]

# TODO: does not work for EMBL datasets, problem with opening version 0.6-dev
@pytest.mark.skip(reason="Problem with ome_zarr on test datasets: ValueError: Version 0.6-dev not recognized")
def test_remote(self, s3_address):
# TODO: remove selection once support for points, shapes and tables is added
sdata = SpatialData.read(s3_address, selection=("images", "labels"))
assert len(list(sdata.gen_elements())) > 0

@pytest.mark.skip(reason="Problem with ome_zarr on test datasets: ValueError: Version 0.6-dev not recognized")
def test_remote_consolidated(self, s3_address):
# TODO: find a way to check if the consolidated metadata is actually used. Probably best to wait for Zarr v3.
root = zarr.open_consolidated(s3_address, mode="r", metadata_key="zmetadata")
# TODO: remove selection once support for points, shapes and tables is added
urlpath, storage_options = str(s3_address), getattr(s3_address, "storage_options", {})
root = zarr.open_consolidated(urlpath, mode="r", metadata_key="zmetadata", storage_options=storage_options)
sdata = SpatialData.read(root, selection=("images", "labels"))
assert len(list(sdata.gen_elements())) > 0
Loading