Skip to content

Commit 1d969d5

Browse files
committed
chore: make_store_path is private
1 parent bd6dc14 commit 1d969d5

File tree

7 files changed

+44
-33
lines changed

7 files changed

+44
-33
lines changed

src/zarr/api/asynchronous.py

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,14 @@
2727
from zarr.core.metadata import ArrayMetadataDict, ArrayV2Metadata, ArrayV3Metadata
2828
from zarr.core.metadata.v2 import _default_filters_and_compressor
2929
from zarr.errors import NodeTypeValidationError
30-
from zarr.storage import (
31-
StoreLike,
32-
make_store_path,
33-
)
30+
from zarr.storage._common import _make_store_path
3431

3532
if TYPE_CHECKING:
3633
from collections.abc import Iterable
3734

3835
from zarr.abc.codec import Codec
3936
from zarr.core.chunk_key_encodings import ChunkKeyEncoding
37+
from zarr.storage import StoreLike
4038

4139
# TODO: this type could use some more thought
4240
ArrayLike = AsyncArray[ArrayV2Metadata] | AsyncArray[ArrayV3Metadata] | Array | npt.NDArray[Any]
@@ -186,7 +184,7 @@ async def consolidate_metadata(
186184
The group, with the ``consolidated_metadata`` field set to include
187185
the metadata of each child node.
188186
"""
189-
store_path = await make_store_path(store, path=path)
187+
store_path = await _make_store_path(store, path=path)
190188

191189
group = await AsyncGroup.open(store_path, zarr_format=zarr_format, use_consolidated=False)
192190
group.store_path.store._check_writable()
@@ -313,7 +311,9 @@ async def open(
313311
"""
314312
zarr_format = _handle_zarr_version_or_format(zarr_version=zarr_version, zarr_format=zarr_format)
315313

316-
store_path = await make_store_path(store, mode=mode, path=path, storage_options=storage_options)
314+
store_path = await _make_store_path(
315+
store, mode=mode, path=path, storage_options=storage_options
316+
)
317317

318318
# TODO: the mode check below seems wrong!
319319
if "shape" not in kwargs and mode in {"a", "r", "r+"}:
@@ -423,7 +423,9 @@ async def save_array(
423423
raise TypeError("arr argument must be numpy or other NDArrayLike array")
424424

425425
mode = kwargs.pop("mode", "a")
426-
store_path = await make_store_path(store, path=path, mode=mode, storage_options=storage_options)
426+
store_path = await _make_store_path(
427+
store, path=path, mode=mode, storage_options=storage_options
428+
)
427429
if np.isscalar(arr):
428430
arr = np.array(arr)
429431
shape = arr.shape
@@ -470,7 +472,7 @@ async def save_group(
470472
NumPy arrays with data to save.
471473
"""
472474

473-
store_path = await make_store_path(store, path=path, mode="w", storage_options=storage_options)
475+
store_path = await _make_store_path(store, path=path, mode="w", storage_options=storage_options)
474476

475477
zarr_format = (
476478
_handle_zarr_version_or_format(
@@ -640,7 +642,9 @@ async def group(
640642
mode = "w"
641643
else:
642644
mode = "r+"
643-
store_path = await make_store_path(store, path=path, mode=mode, storage_options=storage_options)
645+
store_path = await _make_store_path(
646+
store, path=path, mode=mode, storage_options=storage_options
647+
)
644648

645649
if chunk_store is not None:
646650
warnings.warn("chunk_store is not yet implemented", RuntimeWarning, stacklevel=2)
@@ -754,7 +758,9 @@ async def open_group(
754758
if chunk_store is not None:
755759
warnings.warn("chunk_store is not yet implemented", RuntimeWarning, stacklevel=2)
756760

757-
store_path = await make_store_path(store, mode=mode, storage_options=storage_options, path=path)
761+
store_path = await _make_store_path(
762+
store, mode=mode, storage_options=storage_options, path=path
763+
)
758764

759765
if attributes is None:
760766
attributes = {}
@@ -969,7 +975,9 @@ async def create(
969975
mode = kwargs.pop("mode", None)
970976
if mode is None:
971977
mode = "a"
972-
store_path = await make_store_path(store, path=path, mode=mode, storage_options=storage_options)
978+
store_path = await _make_store_path(
979+
store, path=path, mode=mode, storage_options=storage_options
980+
)
973981

974982
config_dict: ArrayConfigParams = {}
975983

@@ -1182,7 +1190,9 @@ async def open_array(
11821190
"""
11831191

11841192
mode = kwargs.pop("mode", None)
1185-
store_path = await make_store_path(store, path=path, mode=mode, storage_options=storage_options)
1193+
store_path = await _make_store_path(
1194+
store, path=path, mode=mode, storage_options=storage_options
1195+
)
11861196

11871197
zarr_format = _handle_zarr_version_or_format(zarr_version=zarr_version, zarr_format=zarr_format)
11881198

src/zarr/core/array.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,15 @@
8585
from zarr.core.sync import sync
8686
from zarr.errors import MetadataValidationError
8787
from zarr.registry import get_pipeline_class
88-
from zarr.storage import StoreLike, make_store_path
89-
from zarr.storage._common import StorePath, ensure_no_existing_node
88+
from zarr.storage._common import StorePath, _make_store_path, ensure_no_existing_node
9089

9190
if TYPE_CHECKING:
9291
from collections.abc import Iterable, Iterator, Sequence
9392
from typing import Self
9493

9594
from zarr.abc.codec import Codec, CodecPipeline
9695
from zarr.core.group import AsyncGroup
96+
from zarr.storage import StoreLike
9797

9898
# Array and AsyncArray are defined in the base ``zarr`` namespace
9999
__all__ = ["create_codec_pipeline", "parse_array_metadata"]
@@ -490,7 +490,7 @@ async def create(
490490
<AsyncArray memory://140349042942400 shape=(100, 100) dtype=int32>
491491
492492
"""
493-
store_path = await make_store_path(store)
493+
store_path = await _make_store_path(store)
494494

495495
dtype_parsed = parse_dtype(dtype, zarr_format)
496496
shape = parse_shapelike(shape)
@@ -752,7 +752,7 @@ async def open(
752752
>>> async_arr = await AsyncArray.open(store) # doctest: +ELLIPSIS
753753
<AsyncArray memory://... shape=(100, 100) dtype=int32>
754754
"""
755-
store_path = await make_store_path(store)
755+
store_path = await _make_store_path(store)
756756
metadata_dict = await get_array_metadata(store_path, zarr_format=zarr_format)
757757
# TODO: remove this cast when we have better type hints
758758
_metadata_dict = cast(ArrayV3MetadataDict, metadata_dict)

src/zarr/core/group.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
from zarr.core.metadata.v3 import V3JsonEncoder
4040
from zarr.core.sync import SyncMixin, sync
4141
from zarr.errors import MetadataValidationError
42-
from zarr.storage import StoreLike, StorePath, make_store_path
43-
from zarr.storage._common import ensure_no_existing_node
42+
from zarr.storage import StoreLike, StorePath
43+
from zarr.storage._common import _make_store_path, ensure_no_existing_node
4444

4545
if TYPE_CHECKING:
4646
from collections.abc import AsyncGenerator, Generator, Iterable, Iterator
@@ -413,7 +413,7 @@ async def from_store(
413413
overwrite: bool = False,
414414
zarr_format: ZarrFormat = 3,
415415
) -> AsyncGroup:
416-
store_path = await make_store_path(store)
416+
store_path = await _make_store_path(store)
417417

418418
if overwrite:
419419
if store_path.store.supports_deletes:
@@ -460,7 +460,7 @@ async def open(
460460
(``.zmetadata`` by default). Specify the custom key as ``use_consolidated``
461461
to load consolidated metadata from a non-default key.
462462
"""
463-
store_path = await make_store_path(store)
463+
store_path = await _make_store_path(store)
464464

465465
consolidated_key = ZMETADATA_V2_JSON
466466

src/zarr/storage/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from types import ModuleType
44
from typing import Any
55

6-
from zarr.storage._common import StoreLike, StorePath, make_store_path
6+
from zarr.storage._common import StoreLike, StorePath
77
from zarr.storage._fsspec import FsspecStore
88
from zarr.storage._local import LocalStore
99
from zarr.storage._logging import LoggingStore
@@ -21,7 +21,6 @@
2121
"StorePath",
2222
"WrapperStore",
2323
"ZipStore",
24-
"make_store_path",
2524
]
2625

2726

src/zarr/storage/_common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ def __eq__(self, other: object) -> bool:
227227
StoreLike = Store | StorePath | Path | str | dict[str, Buffer]
228228

229229

230-
async def make_store_path(
230+
async def _make_store_path(
231231
store_like: StoreLike | None,
232232
*,
233233
path: str | None = "",

tests/test_group.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
from zarr.core.group import ConsolidatedMetadata, GroupMetadata
2222
from zarr.core.sync import sync
2323
from zarr.errors import ContainsArrayError, ContainsGroupError
24-
from zarr.storage import LocalStore, MemoryStore, StorePath, ZipStore, make_store_path
24+
from zarr.storage import LocalStore, MemoryStore, StorePath, ZipStore
25+
from zarr.storage._common import _make_store_path
2526

2627
from .conftest import parse_store
2728

@@ -767,7 +768,7 @@ async def test_asyncgroup_create(
767768
)
768769

769770
assert agroup.metadata == GroupMetadata(zarr_format=zarr_format, attributes=attributes)
770-
assert agroup.store_path == await make_store_path(store)
771+
assert agroup.store_path == await _make_store_path(store)
771772

772773
if not overwrite:
773774
with pytest.raises(ContainsGroupError):

tests/test_store/test_core.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
from _pytest.compat import LEGACY_PATH
66

77
from zarr.core.common import AccessModeLiteral
8-
from zarr.storage import FsspecStore, LocalStore, MemoryStore, StoreLike, StorePath, make_store_path
8+
from zarr.storage import FsspecStore, LocalStore, MemoryStore, StoreLike, StorePath
9+
from zarr.storage._common import _make_store_path
910
from zarr.storage._utils import normalize_path
1011

1112

@@ -14,7 +15,7 @@ async def test_make_store_path_none(path: str) -> None:
1415
"""
1516
Test that creating a store_path with None creates a memorystore
1617
"""
17-
store_path = await make_store_path(None, path=path)
18+
store_path = await _make_store_path(None, path=path)
1819
assert isinstance(store_path.store, MemoryStore)
1920
assert store_path.path == normalize_path(path)
2021

@@ -32,7 +33,7 @@ async def test_make_store_path_local(
3233
Test the various ways of invoking make_store_path that create a LocalStore
3334
"""
3435
store_like = store_type(str(tmpdir))
35-
store_path = await make_store_path(store_like, path=path, mode=mode)
36+
store_path = await _make_store_path(store_like, path=path, mode=mode)
3637
assert isinstance(store_path.store, LocalStore)
3738
assert Path(store_path.store.root) == Path(tmpdir)
3839
assert store_path.path == normalize_path(path)
@@ -50,7 +51,7 @@ async def test_make_store_path_store_path(
5051
"""
5152
ro = mode == "r"
5253
store_like = await StorePath.open(LocalStore(str(tmpdir), read_only=ro), path="root", mode=mode)
53-
store_path = await make_store_path(store_like, path=path, mode=mode)
54+
store_path = await _make_store_path(store_like, path=path, mode=mode)
5455
assert isinstance(store_path.store, LocalStore)
5556
assert Path(store_path.store.root) == Path(tmpdir)
5657
path_normalized = normalize_path(path)
@@ -64,12 +65,12 @@ async def test_make_store_path_invalid() -> None:
6465
Test that invalid types raise TypeError
6566
"""
6667
with pytest.raises(TypeError):
67-
await make_store_path(1) # type: ignore[arg-type]
68+
await _make_store_path(1) # type: ignore[arg-type]
6869

6970

7071
async def test_make_store_path_fsspec(monkeypatch) -> None:
7172
pytest.importorskip("fsspec")
72-
store_path = await make_store_path("http://foo.com/bar")
73+
store_path = await _make_store_path("http://foo.com/bar")
7374
assert isinstance(store_path.store, FsspecStore)
7475

7576

@@ -86,12 +87,12 @@ async def test_make_store_path_fsspec(monkeypatch) -> None:
8687
)
8788
async def test_make_store_path_storage_options_raises(store_like: StoreLike) -> None:
8889
with pytest.raises(TypeError, match="storage_options"):
89-
await make_store_path(store_like, storage_options={"foo": "bar"})
90+
await _make_store_path(store_like, storage_options={"foo": "bar"})
9091

9192

9293
async def test_unsupported() -> None:
9394
with pytest.raises(TypeError, match="Unsupported type for store_like: 'int'"):
94-
await make_store_path(1) # type: ignore[arg-type]
95+
await _make_store_path(1) # type: ignore[arg-type]
9596

9697

9798
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)