From 312c298b79fe465494ad45583ff701e5229b99c2 Mon Sep 17 00:00:00 2001 From: Max Jones <14077947+maxrjones@users.noreply.github.com> Date: Thu, 6 Feb 2025 12:50:39 -0500 Subject: [PATCH 1/3] Strenghten serialization test --- src/zarr/testing/store.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/zarr/testing/store.py b/src/zarr/testing/store.py index 00427f6a0e..112f6261e9 100644 --- a/src/zarr/testing/store.py +++ b/src/zarr/testing/store.py @@ -99,10 +99,16 @@ def test_store_eq(self, store: S, store_kwargs: dict[str, Any]) -> None: store2 = self.store_cls(**store_kwargs) assert store == store2 - def test_serializable_store(self, store: S) -> None: + async def test_serializable_store(self, store: S) -> None: new_store: S = pickle.loads(pickle.dumps(store)) assert new_store == store assert new_store.read_only == store.read_only + # quickly roundtrip data to a key to test that new store works + data_buf = self.buffer_cls.from_bytes(b"\x01\x02\x03\x04") + key = "foo" + await store.set(key, data_buf) + observed = await store.get(key, prototype=default_buffer_prototype()) + assert_bytes_equal(observed, data_buf) def test_store_read_only(self, store: S) -> None: assert not store.read_only From a80ae45c51caa6ca51e341d6c9e11c7c930db50d Mon Sep 17 00:00:00 2001 From: Max Jones <14077947+maxrjones@users.noreply.github.com> Date: Thu, 6 Feb 2025 13:13:02 -0500 Subject: [PATCH 2/3] Fix ZipStore serialization --- src/zarr/storage/_zip.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/zarr/storage/_zip.py b/src/zarr/storage/_zip.py index bf8f9900b9..51bb702c27 100644 --- a/src/zarr/storage/_zip.py +++ b/src/zarr/storage/_zip.py @@ -108,7 +108,8 @@ async def _open(self) -> None: self._sync_open() def __getstate__(self) -> dict[str, Any]: - state = self.__dict__ + # We need a copy to not modify the state of the original store + state = self.__dict__.copy() for attr in ["_zf", "_lock"]: state.pop(attr, None) return state From cfd8f1270e69faa7925cdfd9e7b616df31a58a58 Mon Sep 17 00:00:00 2001 From: Max Jones <14077947+maxrjones@users.noreply.github.com> Date: Thu, 6 Feb 2025 16:01:31 -0500 Subject: [PATCH 3/3] Add changelog bug fix --- changes/2807.bugfix.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 changes/2807.bugfix.rst diff --git a/changes/2807.bugfix.rst b/changes/2807.bugfix.rst new file mode 100644 index 0000000000..ae0eb2f6ac --- /dev/null +++ b/changes/2807.bugfix.rst @@ -0,0 +1 @@ +Fix pickling for ZipStore