diff --git a/changes/4505.bugfix.md b/changes/4505.bugfix.md new file mode 100644 index 0000000000..8d50b8efb6 --- /dev/null +++ b/changes/4505.bugfix.md @@ -0,0 +1 @@ +The `zarr.storage` module can now be serialized with `cloudpickle`. Previously, code that referenced the module (for example a Dask task that used `zarr.storage.ObjectStore`) failed with `TypeError: cannot pickle 'VerboseModule' object`. diff --git a/changes/4505.removal.md b/changes/4505.removal.md new file mode 100644 index 0000000000..6549a77c95 --- /dev/null +++ b/changes/4505.removal.md @@ -0,0 +1 @@ +Setting `zarr.storage.default_compressor` no longer emits a deprecation warning. The attribute has had no effect since 3.0.0; configure `array.v2_default_compressor` through `zarr.config` instead. diff --git a/src/zarr/storage/__init__.py b/src/zarr/storage/__init__.py index f1bd1724af..1c41082ba7 100644 --- a/src/zarr/storage/__init__.py +++ b/src/zarr/storage/__init__.py @@ -1,9 +1,3 @@ -import sys -import warnings -from types import ModuleType -from typing import Any - -from zarr.errors import ZarrDeprecationWarning from zarr.storage._common import StoreLike, StorePath from zarr.storage._fsspec import FsspecStore from zarr.storage._local import LocalStore @@ -26,20 +20,3 @@ "WrapperStore", "ZipStore", ] - - -class VerboseModule(ModuleType): - def __setattr__(self, attr: str, value: Any) -> None: - if attr == "default_compressor": - warnings.warn( - "setting zarr.storage.default_compressor is deprecated, use " - "zarr.config to configure array.v2_default_compressor " - "e.g. config.set({'codecs.zstd':'numcodecs.Zstd', 'array.v2_default_compressor.numeric': 'zstd'})", - ZarrDeprecationWarning, - stacklevel=1, - ) - else: - super().__setattr__(attr, value) - - -sys.modules[__name__].__class__ = VerboseModule diff --git a/tests/test_v2.py b/tests/test_v2.py index 2e04339441..9a36aca74b 100644 --- a/tests/test_v2.py +++ b/tests/test_v2.py @@ -20,7 +20,6 @@ from zarr.core.dtype.wrapper import ZDType from zarr.core.group import Group from zarr.core.sync import sync -from zarr.errors import ZarrDeprecationWarning from zarr.storage import MemoryStore, StorePath @@ -225,11 +224,6 @@ def test_v2_non_contiguous(numpy_order: Literal["C", "F"], zarr_order: Literal[" assert (sub_arr).flags.c_contiguous -def test_default_compressor_deprecation_warning() -> None: - with pytest.warns(ZarrDeprecationWarning, match="default_compressor is deprecated"): - zarr.storage.default_compressor = "zarr.codecs.zstd.ZstdCodec()" # type: ignore[attr-defined] - - @pytest.mark.parametrize("fill_value", [None, (b"", 0, 0.0)], ids=["no_fill", "fill"]) def test_structured_dtype_roundtrip(fill_value: float | bytes, tmp_path: Path) -> None: a = np.array(