Skip to content

Commit

Permalink
Clean up public store API
Browse files Browse the repository at this point in the history
  • Loading branch information
dstansby committed Jan 2, 2025
1 parent b9699f5 commit b7423e8
Show file tree
Hide file tree
Showing 32 changed files with 38 additions and 45 deletions.
2 changes: 1 addition & 1 deletion src/zarr/core/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
from zarr.errors import MetadataValidationError
from zarr.registry import get_pipeline_class
from zarr.storage import StoreLike, make_store_path
from zarr.storage.common import StorePath, ensure_no_existing_node
from zarr.storage._common import StorePath, ensure_no_existing_node

if TYPE_CHECKING:
from collections.abc import Iterable, Iterator, Sequence
Expand Down
4 changes: 2 additions & 2 deletions src/zarr/core/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
from zarr.core.metadata.v3 import V3JsonEncoder
from zarr.core.sync import SyncMixin, sync
from zarr.errors import MetadataValidationError
from zarr.storage import StoreLike, make_store_path
from zarr.storage.common import StorePath, ensure_no_existing_node
from zarr.storage import StoreLike, StorePath, make_store_path
from zarr.storage._common import ensure_no_existing_node

if TYPE_CHECKING:
from collections.abc import AsyncGenerator, Generator, Iterable, Iterator
Expand Down
15 changes: 8 additions & 7 deletions src/zarr/storage/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@
from types import ModuleType
from typing import Any

from zarr.storage.common import StoreLike, StorePath, make_store_path
from zarr.storage.fsspec import FsspecStore
from zarr.storage.local import LocalStore
from zarr.storage.logging import LoggingStore
from zarr.storage.memory import MemoryStore
from zarr.storage.wrapper import WrapperStore
from zarr.storage.zip import ZipStore
from zarr.storage._common import StoreLike, StorePath, make_store_path
from zarr.storage._fsspec import FsspecStore
from zarr.storage._local import LocalStore
from zarr.storage._logging import LoggingStore
from zarr.storage._memory import GpuMemoryStore, MemoryStore
from zarr.storage._wrapper import WrapperStore
from zarr.storage._zip import ZipStore

__all__ = [
"FsspecStore",
"GpuMemoryStore",
"LocalStore",
"LoggingStore",
"MemoryStore",
Expand Down
6 changes: 3 additions & 3 deletions src/zarr/storage/common.py → src/zarr/storage/_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
from zarr.core.buffer import Buffer, default_buffer_prototype
from zarr.core.common import ZARR_JSON, ZARRAY_JSON, ZGROUP_JSON, AccessModeLiteral, ZarrFormat
from zarr.errors import ContainsArrayAndGroupError, ContainsArrayError, ContainsGroupError
from zarr.storage._local import LocalStore
from zarr.storage._memory import MemoryStore
from zarr.storage._utils import normalize_path
from zarr.storage.local import LocalStore
from zarr.storage.memory import MemoryStore

if TYPE_CHECKING:
from zarr.core.buffer import BufferPrototype
Expand Down Expand Up @@ -281,7 +281,7 @@ async def make_store_path(
TypeError
If the StoreLike object is not one of the supported types.
"""
from zarr.storage.fsspec import FsspecStore # circular import
from zarr.storage._fsspec import FsspecStore # circular import

used_storage_options = False
path_normalized = normalize_path(path)
Expand Down
2 changes: 1 addition & 1 deletion src/zarr/storage/fsspec.py → src/zarr/storage/_fsspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from typing import TYPE_CHECKING, Any

from zarr.abc.store import ByteRangeRequest, Store
from zarr.storage.common import _dereference_path
from zarr.storage._common import _dereference_path

if TYPE_CHECKING:
from collections.abc import AsyncIterator, Iterable
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from typing import TYPE_CHECKING, Any

from zarr.abc.store import Store
from zarr.storage.wrapper import WrapperStore
from zarr.storage._wrapper import WrapperStore

if TYPE_CHECKING:
from collections.abc import AsyncIterator, Generator, Iterable
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/zarr/testing/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pickle
from typing import TYPE_CHECKING, Generic, TypeVar

from zarr.storage.wrapper import WrapperStore
from zarr.storage import WrapperStore

if TYPE_CHECKING:
from typing import Any
Expand Down
3 changes: 1 addition & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
from zarr import AsyncGroup, config
from zarr.abc.store import Store
from zarr.core.sync import sync
from zarr.storage import LocalStore, MemoryStore, StorePath, ZipStore
from zarr.storage.fsspec import FsspecStore
from zarr.storage import FsspecStore, LocalStore, MemoryStore, StorePath, ZipStore

if TYPE_CHECKING:
from collections.abc import Generator
Expand Down
2 changes: 1 addition & 1 deletion tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
)
from zarr.core.common import MemoryOrder, ZarrFormat
from zarr.errors import MetadataValidationError
from zarr.storage import MemoryStore
from zarr.storage._utils import normalize_path
from zarr.storage.memory import MemoryStore


def test_create_array(memory_store: Store) -> None:
Expand Down
3 changes: 1 addition & 2 deletions tests/test_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
from zarr.core.metadata.v3 import DataType
from zarr.core.sync import sync
from zarr.errors import ContainsArrayError, ContainsGroupError
from zarr.storage import LocalStore, MemoryStore
from zarr.storage.common import StorePath
from zarr.storage import LocalStore, MemoryStore, StorePath


@pytest.mark.parametrize("store", ["local", "memory", "zip"], indirect=["store"])
Expand Down
3 changes: 1 addition & 2 deletions tests/test_buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
from zarr.codecs.transpose import TransposeCodec
from zarr.codecs.zstd import ZstdCodec
from zarr.core.buffer import ArrayLike, BufferPrototype, NDArrayLike, cpu, gpu
from zarr.storage.common import StorePath
from zarr.storage.memory import MemoryStore
from zarr.storage import MemoryStore, StorePath
from zarr.testing.buffer import (
NDBufferUsingTestNDArrayLike,
StoreExpectingTestBuffer,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_codecs/test_blosc.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from zarr.abc.store import Store
from zarr.codecs import BloscCodec, BytesCodec, ShardingCodec
from zarr.core.buffer import default_buffer_prototype
from zarr.storage.common import StorePath
from zarr.storage import StorePath


@pytest.mark.parametrize("store", ["local", "memory"], indirect=["store"])
Expand Down
2 changes: 1 addition & 1 deletion tests/test_codecs/test_endian.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from zarr import AsyncArray
from zarr.abc.store import Store
from zarr.codecs import BytesCodec
from zarr.storage.common import StorePath
from zarr.storage import StorePath

from .test_codecs import _AsyncArrayProxy

Expand Down
2 changes: 1 addition & 1 deletion tests/test_codecs/test_gzip.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from zarr import Array
from zarr.abc.store import Store
from zarr.codecs import BytesCodec, GzipCodec
from zarr.storage.common import StorePath
from zarr.storage import StorePath


@pytest.mark.parametrize("store", ["local", "memory"], indirect=["store"])
Expand Down
2 changes: 1 addition & 1 deletion tests/test_codecs/test_sharding.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
TransposeCodec,
)
from zarr.core.buffer import default_buffer_prototype
from zarr.storage.common import StorePath
from zarr.storage import StorePath

from ..conftest import ArrayRequest
from .test_codecs import _AsyncArrayProxy, order_from_dim
Expand Down
2 changes: 1 addition & 1 deletion tests/test_codecs/test_transpose.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from zarr.abc.store import Store
from zarr.codecs import BytesCodec, ShardingCodec, TransposeCodec
from zarr.core.common import MemoryOrder
from zarr.storage.common import StorePath
from zarr.storage import StorePath

from .test_codecs import _AsyncArrayProxy

Expand Down
2 changes: 1 addition & 1 deletion tests/test_codecs/test_vlen.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from zarr.codecs import VLenBytesCodec, VLenUTF8Codec, ZstdCodec
from zarr.core.metadata.v3 import ArrayV3Metadata, DataType
from zarr.core.strings import _NUMPY_SUPPORTS_VLEN_STRING
from zarr.storage.common import StorePath
from zarr.storage import StorePath

numpy_str_dtypes: list[type | str | None] = [None, str, "str", np.dtypes.StrDType]
expected_zarr_string_dtype: np.dtype[Any]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_codecs/test_zstd.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from zarr import Array
from zarr.abc.store import Store
from zarr.codecs import BytesCodec, ZstdCodec
from zarr.storage.common import StorePath
from zarr.storage import StorePath


@pytest.mark.parametrize("store", ["local", "memory"], indirect=["store"])
Expand Down
3 changes: 1 addition & 2 deletions tests/test_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
from zarr.core.group import ConsolidatedMetadata, GroupMetadata
from zarr.core.sync import sync
from zarr.errors import ContainsArrayError, ContainsGroupError
from zarr.storage import LocalStore, MemoryStore, StorePath, ZipStore
from zarr.storage.common import make_store_path
from zarr.storage import LocalStore, MemoryStore, StorePath, ZipStore, make_store_path

from .conftest import parse_store

Expand Down
3 changes: 1 addition & 2 deletions tests/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
replace_ellipsis,
)
from zarr.registry import get_ndbuffer_class
from zarr.storage.common import StorePath
from zarr.storage.memory import MemoryStore
from zarr.storage import MemoryStore, StorePath

if TYPE_CHECKING:
from collections.abc import AsyncGenerator
Expand Down
2 changes: 1 addition & 1 deletion tests/test_metadata/test_consolidated.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from zarr.core.group import ConsolidatedMetadata, GroupMetadata
from zarr.core.metadata import ArrayV3Metadata
from zarr.core.metadata.v2 import ArrayV2Metadata
from zarr.storage.common import StorePath
from zarr.storage import StorePath

if TYPE_CHECKING:
from zarr.abc.store import Store
Expand Down
5 changes: 1 addition & 4 deletions tests/test_store/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@
from _pytest.compat import LEGACY_PATH

from zarr.core.common import AccessModeLiteral
from zarr.storage import FsspecStore, LocalStore, MemoryStore, StoreLike, StorePath, make_store_path
from zarr.storage._utils import normalize_path
from zarr.storage.common import StoreLike, StorePath, make_store_path
from zarr.storage.fsspec import FsspecStore
from zarr.storage.local import LocalStore
from zarr.storage.memory import MemoryStore


@pytest.mark.parametrize("path", [None, "", "bar"])
Expand Down
2 changes: 1 addition & 1 deletion tests/test_store/test_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import zarr
from zarr.core.buffer import Buffer, cpu
from zarr.storage.local import LocalStore
from zarr.storage import LocalStore
from zarr.testing.store import StoreTests

if TYPE_CHECKING:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_store/test_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import zarr
from zarr.core.buffer import default_buffer_prototype
from zarr.storage.logging import LoggingStore
from zarr.storage import LoggingStore

if TYPE_CHECKING:
from zarr.abc.store import Store
Expand Down
2 changes: 1 addition & 1 deletion tests/test_store/test_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pytest

from zarr.core.buffer import Buffer, cpu, gpu
from zarr.storage.memory import GpuMemoryStore, MemoryStore
from zarr.storage import GpuMemoryStore, MemoryStore
from zarr.testing.store import StoreTests
from zarr.testing.utils import gpu_test

Expand Down
2 changes: 1 addition & 1 deletion tests/test_store/test_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import pytest

from zarr.core.buffer.cpu import Buffer, buffer_prototype
from zarr.storage.wrapper import WrapperStore
from zarr.storage import WrapperStore

if TYPE_CHECKING:
from zarr.abc.store import Store
Expand Down
2 changes: 1 addition & 1 deletion tests/test_store/test_zip.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import zarr
from zarr.core.buffer import Buffer, cpu, default_buffer_prototype
from zarr.storage.zip import ZipStore
from zarr.storage import ZipStore
from zarr.testing.store import StoreTests

if TYPE_CHECKING:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
cleanup_resources,
sync,
)
from zarr.storage.memory import MemoryStore
from zarr.storage import MemoryStore


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

0 comments on commit b7423e8

Please sign in to comment.