diff --git a/CHANGELOG.md b/CHANGELOG.md index 2420eb28..a0a7602f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## [Unreleased] + +### Fixes + +- `fractal_fsspec_store` accepts OME-Zarr 0.5 (zarr v3) stores. Its reachability probe only fetched the zarr v2 keys `.zgroup` and `.zarray`, so any v3 store, which has a `zarr.json` instead, raised `NgioValueError("Store ... can not be read")` even though the data was reachable. The probe now tries `zarr.json` first; the missing/invalid `fractal_token` errors apply to v3 stores too ([#289](https://github.com/BioVisionCenter/ngio/issues/289)). + ## [v1.1.4] ### Features diff --git a/src/ngio/utils/_fractal_fsspec_store.py b/src/ngio/utils/_fractal_fsspec_store.py index c2afcb28..25eec811 100644 --- a/src/ngio/utils/_fractal_fsspec_store.py +++ b/src/ngio/utils/_fractal_fsspec_store.py @@ -45,7 +45,8 @@ def fractal_fsspec_store( store = fs.get_mapper(url) - possible_keys = [".zgroup", ".zarray"] + # zarr v3 (`zarr.json`) first, then the zarr v2 keys. + possible_keys = ["zarr.json", ".zgroup", ".zarray"] for key in possible_keys: value = _probe_key(store, url, key, fractal_token) if value is not None: diff --git a/tests/stores/test_http_store.py b/tests/stores/test_http_store.py index 9a041acf..4f05f004 100644 --- a/tests/stores/test_http_store.py +++ b/tests/stores/test_http_store.py @@ -10,8 +10,8 @@ random_zarr_path, ) -from ngio import open_ome_zarr_container -from ngio.utils import NgioValueError +from ngio import create_empty_ome_zarr, open_ome_zarr_container +from ngio.utils import NgioValueError, fractal_fsspec_store HTTP_STORE_SUPPORTED_BACKENDS = ["anndata", "json", "csv", "parquet"] @@ -80,3 +80,25 @@ def test_http_store_derive_to_memory_store(http_static_server: dict) -> None: other_store = {} with pytest.raises(NgioValueError, match="not listable"): derive_image(ome_zarr, other_store=other_store) + + +@pytest.mark.parametrize("ngff_version", ["0.4", "0.5"]) +def test_fractal_fsspec_store(http_static_server: dict, ngff_version: str) -> None: + # 0.5 is zarr v3: the store has a `zarr.json` and no `.zgroup` (#289). + url, root = http_static_server["url"], http_static_server["root"] + zarr_path = random_zarr_path() + create_empty_ome_zarr( + root / zarr_path, + shape=(8, 8), + pixelsize=0.5, + levels=1, + ngff_version=ngff_version, + ) + store = fractal_fsspec_store(f"{url}/{zarr_path}") + assert open_ome_zarr_container(store).get_image().shape == (8, 8) + + +def test_fractal_fsspec_store_not_a_zarr(http_static_server: dict) -> None: + url = http_static_server["url"] + with pytest.raises(NgioValueError, match="can not be read"): + fractal_fsspec_store(f"{url}/{random_zarr_path()}")