From f8943351b0424e06856271275a9c3c93140775b2 Mon Sep 17 00:00:00 2001 From: Tom Augspurger Date: Thu, 19 Sep 2024 12:40:20 -0500 Subject: [PATCH] Make MemoryStore serialiazable (#2204) --- src/zarr/store/memory.py | 8 +------- tests/v3/test_store/test_memory.py | 22 ---------------------- 2 files changed, 1 insertion(+), 29 deletions(-) diff --git a/src/zarr/store/memory.py b/src/zarr/store/memory.py index e304419768..7baa6aee26 100644 --- a/src/zarr/store/memory.py +++ b/src/zarr/store/memory.py @@ -1,7 +1,7 @@ from __future__ import annotations from collections.abc import AsyncGenerator, MutableMapping -from typing import TYPE_CHECKING, Any +from typing import TYPE_CHECKING from zarr.abc.store import Store from zarr.core.buffer import Buffer, gpu @@ -55,12 +55,6 @@ def __eq__(self, other: object) -> bool: and self.mode == other.mode ) - def __setstate__(self, state: Any) -> None: - raise NotImplementedError(f"{type(self)} cannot be pickled") - - def __getstate__(self) -> None: - raise NotImplementedError(f"{type(self)} cannot be pickled") - async def get( self, key: str, diff --git a/tests/v3/test_store/test_memory.py b/tests/v3/test_store/test_memory.py index 470383dfb6..2498cdc24a 100644 --- a/tests/v3/test_store/test_memory.py +++ b/tests/v3/test_store/test_memory.py @@ -1,7 +1,5 @@ from __future__ import annotations -import pickle - import pytest from zarr.core.buffer import Buffer, cpu, gpu @@ -48,16 +46,6 @@ def test_store_supports_partial_writes(self, store: MemoryStore) -> None: def test_list_prefix(self, store: MemoryStore) -> None: assert True - def test_serizalizable_store(self, store: MemoryStore) -> None: - with pytest.raises(NotImplementedError): - store.__getstate__() - - with pytest.raises(NotImplementedError): - store.__setstate__({}) - - with pytest.raises(NotImplementedError): - pickle.dumps(store) - @gpu_test class TestGpuMemoryStore(StoreTests[GpuMemoryStore, gpu.Buffer]): @@ -92,13 +80,3 @@ def test_store_supports_partial_writes(self, store: GpuMemoryStore) -> None: def test_list_prefix(self, store: GpuMemoryStore) -> None: assert True - - def test_serizalizable_store(self, store: MemoryStore) -> None: - with pytest.raises(NotImplementedError): - store.__getstate__() - - with pytest.raises(NotImplementedError): - store.__setstate__({}) - - with pytest.raises(NotImplementedError): - pickle.dumps(store)