Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make MemoryStore serializable #2204

Merged
merged 2 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions src/zarr/store/memory.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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,
Expand Down
22 changes: 0 additions & 22 deletions tests/v3/test_store/test_memory.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from __future__ import annotations

import pickle

import pytest

from zarr.core.buffer import Buffer, cpu, gpu
Expand Down Expand Up @@ -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]):
Expand Down Expand Up @@ -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)