diff --git a/python/kvikio/zarr.py b/python/kvikio/zarr.py index 481e6e96d6..b6f8154b72 100644 --- a/python/kvikio/zarr.py +++ b/python/kvikio/zarr.py @@ -381,6 +381,12 @@ def open_cupy_array( meta_array=meta_array, **kwargs, ) + elif not isinstance(ret.compressor, CudaCodec): + raise ValueError( + "The Zarr file was written using a non-CUDA compatible " + f"compressor, {ret.compressor}, please use something " + "like kvikio.zarr.CompatCompressor" + ) return ret if isinstance(compressor, CompatCompressor): diff --git a/python/tests/test_zarr.py b/python/tests/test_zarr.py index f909559eea..cc0ee0ebdd 100644 --- a/python/tests/test_zarr.py +++ b/python/tests/test_zarr.py @@ -245,3 +245,11 @@ def test_open_cupy_array(tmp_path): assert isinstance(z[:], numpy.ndarray) assert z.compressor == kvikio_zarr.CompatCompressor.lz4().cpu numpy.testing.assert_array_equal(a.get(), z[:]) + + +@pytest.mark.parametrize("mode", ["r", "r+"]) +def test_open_cupy_array_incompatible_compressor(tmp_path, mode): + zarr.create((10,), store=tmp_path, compressor=numcodecs.Blosc()) + + with pytest.raises(ValueError, match="non-CUDA compatible compressor"): + kvikio_zarr.open_cupy_array(tmp_path, mode=mode)