Skip to content

data wiped from MemoryStore after store.close + array[:] #2067

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

Closed
wants to merge 5 commits into from
Closed
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
4 changes: 0 additions & 4 deletions src/zarr/abc/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,6 @@ async def _open(self) -> None:
raise FileExistsError("Store already exists")
self._is_open = True

async def _ensure_open(self) -> None:
if not self._is_open:
await self._open()

@abstractmethod
async def empty(self) -> bool: ...

Expand Down
1 change: 1 addition & 0 deletions src/zarr/storage/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ def __init__(self, root: Path | str, *, mode: AccessModeLiteral = "r") -> None:
root = Path(root)
assert isinstance(root, Path)
self.root = root
super().__init__(mode=mode)

async def clear(self) -> None:
self._check_writable()
Expand Down
4 changes: 2 additions & 2 deletions tests/v3/test_buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ async def test_async_array_prototype() -> None:

expect = np.zeros((9, 9), dtype="uint16", order="F")
a = await AsyncArray.create(
StorePath(StoreExpectingTestBuffer(mode="w")) / "test_async_array_prototype",
StorePath(await StoreExpectingTestBuffer.open(mode="w")) / "test_async_array_prototype",
shape=expect.shape,
chunk_shape=(5, 5),
dtype=expect.dtype,
Expand Down Expand Up @@ -99,7 +99,7 @@ async def test_async_array_gpu_prototype() -> None:
async def test_codecs_use_of_prototype() -> None:
expect = np.zeros((10, 10), dtype="uint16", order="F")
a = await AsyncArray.create(
StorePath(StoreExpectingTestBuffer(mode="w")) / "test_codecs_use_of_prototype",
StorePath(await StoreExpectingTestBuffer.open(mode="w")) / "test_codecs_use_of_prototype",
shape=expect.shape,
chunk_shape=(5, 5),
dtype=expect.dtype,
Expand Down
9 changes: 5 additions & 4 deletions tests/v3/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
register_ndbuffer,
register_pipeline,
)
from zarr.sync import sync
from zarr.testing.buffer import (
NDBufferUsingTestNDArrayLike,
StoreExpectingTestBuffer,
Expand Down Expand Up @@ -199,8 +200,8 @@ def test_config_ndbuffer_implementation(store: Store) -> None:
def test_config_buffer_implementation() -> None:
# has default value
assert fully_qualified_name(get_buffer_class()) == config.defaults[0]["buffer"]

arr = zeros(shape=(100), store=StoreExpectingTestBuffer(mode="w"))
store = sync(StoreExpectingTestBuffer.open(mode="w"))
arr = zeros(shape=(100), store=store)

# AssertionError of StoreExpectingTestBuffer when not using my buffer
with pytest.raises(AssertionError):
Expand All @@ -218,15 +219,15 @@ def test_config_buffer_implementation() -> None:
data2d = np.arange(1000).reshape(100, 10)
arr_sharding = zeros(
shape=(100, 10),
store=StoreExpectingTestBuffer(mode="w"),
store=sync(StoreExpectingTestBuffer.open(mode="w")),
codecs=[ShardingCodec(chunk_shape=(10, 10))],
)
arr_sharding[:] = data2d
assert np.array_equal(arr_sharding[:], data2d)

arr_Crc32c = zeros(
shape=(100, 10),
store=StoreExpectingTestBuffer(mode="w"),
store=sync(StoreExpectingTestBuffer.open(mode="w")),
codecs=[BytesCodec(), Crc32cCodec()],
)
arr_Crc32c[:] = data2d
Expand Down
2 changes: 1 addition & 1 deletion tests/v3/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def test_get_basic_selection_0d(store: StorePath, use_out: bool, value: Any, dty
slice(50, 150, 10),
]

basic_selections_1d_bad = [
basic_selections_1d_bad: list[Any] = [
# only positive step supported
slice(None, None, -1),
slice(None, None, -10),
Expand Down