diff --git a/changes/4029.bugfix.md b/changes/4029.bugfix.md deleted file mode 100644 index b4abda7658..0000000000 --- a/changes/4029.bugfix.md +++ /dev/null @@ -1,8 +0,0 @@ -`zarr.storage` is no longer replaced by a `ModuleType` subclass at import time. -The subclass only existed to warn about the long-deprecated -`zarr.storage.default_compressor` attribute, but serializers that dispatch on -the exact type of an object (such as `cloudpickle`, which Dask uses by default) -could not serialize the module and raised -`TypeError: cannot pickle 'VerboseModule' object`. Setting -`zarr.storage.default_compressor` no longer emits a deprecation warning; use -`zarr.config` to configure `array.v2_default_compressor` instead. 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/tests/test_store/test_core.py b/tests/test_store/test_core.py index c928ba8417..f0a2077a8a 100644 --- a/tests/test_store/test_core.py +++ b/tests/test_store/test_core.py @@ -439,12 +439,11 @@ def test_different_open_mode(tmp_path: Path) -> None: def test_storage_module_is_picklable() -> None: - # `zarr.storage` used to be swapped for a `VerboseModule` subclass of - # `types.ModuleType` in order to warn about the long-deprecated - # `zarr.storage.default_compressor` attribute. cloudpickle dispatches on the - # exact type of an object, so the subclass was not registered and - # serializing the module raised `TypeError: cannot pickle 'VerboseModule' - # object`, which broke passing `zarr.storage.ObjectStore` around with Dask. - # See issue #4029. + """ + `zarr.storage` is a plain `types.ModuleType` and round-trips through `cloudpickle`. + + Serializers such as `cloudpickle` dispatch on the exact type of an object, so a + `ModuleType` subclass would not be serializable. See issue #4029. + """ assert type(zarr.storage) is ModuleType assert cloudpickle.loads(cloudpickle.dumps(zarr.storage)) is zarr.storage