Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
more merge conflict resolution
  • Loading branch information
jhamman committed Sep 23, 2024
commit 93b61fca2f7075b47d7bfc70976e24caccdd113e
8 changes: 7 additions & 1 deletion src/zarr/storage/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ async def make_store_path(
mode: AccessModeLiteral | None = None,
storage_options: dict[str, Any] | None = None,
) -> StorePath:
from zarr.store.remote import RemoteStore # circular import
from zarr.storage.remote import RemoteStore # circular import

used_storage_options = False

Expand All @@ -91,10 +91,14 @@ async def make_store_path(
raise ValueError(
f"mode mismatch (mode={mode} != store.mode={store_like.store.mode.str})"
)
if storage_options:
raise TypeError("storage_options passed but store has already been initialized")
return store_like
elif isinstance(store_like, Store):
if (mode is not None) and (AccessMode.from_literal(mode) != store_like.mode):
raise ValueError(f"mode mismatch (mode={mode} != store.mode={store_like.mode.str})")
if storage_options:
raise TypeError("storage_options passed but store has already been initialized")
await store_like._ensure_open()
result = StorePath(store_like)
elif store_like is None:
Expand All @@ -116,6 +120,8 @@ async def make_store_path(
elif isinstance(store_like, dict):
# We deliberate only consider dict[str, Buffer] here, and not arbitrary mutable mappings.
# By only allowing dictionaries, which are in-memory, we know that MemoryStore appropriate.
if mode is None:
mode = "r"
result = StorePath(await MemoryStore.open(store_dict=store_like, mode=mode))
else:
msg = f"Unsupported type for store_like: '{type(store_like).__name__}'" # type: ignore[unreachable]
Expand Down
4 changes: 2 additions & 2 deletions tests/v3/test_attributes.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import zarr.core
import zarr.core.attributes
import zarr.store
import zarr.storage


def test_put() -> None:
store = zarr.store.MemoryStore({}, mode="w")
store = zarr.storage.MemoryStore({}, mode="w")
attrs = zarr.core.attributes.Attributes(
zarr.Group.from_store(store, attributes={"a": 1, "b": 2})
)
Expand Down
2 changes: 1 addition & 1 deletion tests/v3/test_store/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ async def test_make_store_path_fsspec(monkeypatch) -> None:
)
async def test_make_store_path_storage_options_raises(store_like: StoreLike) -> None:
with pytest.raises(TypeError, match="storage_options"):
await make_store_path(store_like, storage_options={"foo": "bar"}, mode="w")
await make_store_path(store_like, storage_options={"foo": "bar"})


async def test_unsupported() -> None:
Expand Down
2 changes: 1 addition & 1 deletion tests/v3/test_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import zarr
from zarr.core.sync import SyncError, SyncMixin, _get_lock, _get_loop, sync
from zarr.store.memory import MemoryStore
from zarr.storage.memory import MemoryStore


@pytest.fixture(params=[True, False])
Expand Down