diff --git a/docs/release.rst b/docs/release.rst index 9873d62896..3ed47ff9f5 100644 --- a/docs/release.rst +++ b/docs/release.rst @@ -13,10 +13,22 @@ Release notes # to document your changes. On releases it will be # re-indented so that it does not show up in the notes. +.. _unreleased(v3): + +Unreleased (v3) +--------------- + +Maintenance +~~~~~~~~~~~ + +* Remedy a situation where ``zarr-python`` was importing ``DummyStorageTransformer`` from the test suite. + The dependency relationship is now reversed: the test suite imports this class from ``zarr-python``. + By :user:`Davis Bennett ` :issue:`1601`. + .. _unreleased: -Unreleased ----------- +Unreleased (v2) +--------------- Docs ~~~~ @@ -61,7 +73,6 @@ Maintenance * Remove ``sphinx-rtd-theme`` dependency from ``pyproject.toml``. By :user:`Sanket Verma ` :issue:`1563`. - .. _release_2.16.1: 2.16.1 diff --git a/zarr/_storage/v3_storage_transformers.py b/zarr/_storage/v3_storage_transformers.py index ff31a7281c..3090aea28c 100644 --- a/zarr/_storage/v3_storage_transformers.py +++ b/zarr/_storage/v3_storage_transformers.py @@ -81,6 +81,22 @@ def create_empty(cls, store: "ShardingStorageTransformer"): ) +class DummyStorageTransfomer(StorageTransformer): + """For testing purposes. This class was previously defined in the test suite and imported + into Zarr, but now it has been moved here and the test suite will import it like any other part + of the Zarr library.""" + + TEST_CONSTANT = "test1234" + + extension_uri = "https://purl.org/zarr/spec/storage_transformers/dummy/1.0" + valid_types = ["dummy_type"] + + def __init__(self, _type, test_value) -> None: + super().__init__(_type) + assert test_value == self.TEST_CONSTANT + self.test_value = test_value + + class ShardingStorageTransformer(StorageTransformer): # lgtm[py/missing-equals] """Implements sharding as a storage transformer, as described in the spec: https://zarr-specs.readthedocs.io/en/latest/extensions/storage-transformers/sharding/v1.0.html diff --git a/zarr/meta.py b/zarr/meta.py index 48791ddf17..bd1f4ee037 100644 --- a/zarr/meta.py +++ b/zarr/meta.py @@ -459,8 +459,10 @@ def _encode_storage_transformer_metadata( @classmethod def _decode_storage_transformer_metadata(cls, meta: Mapping) -> "StorageTransformer": - from zarr.tests.test_storage_v3 import DummyStorageTransfomer - from zarr._storage.v3_storage_transformers import ShardingStorageTransformer + from zarr._storage.v3_storage_transformers import ( + ShardingStorageTransformer, + DummyStorageTransfomer, + ) # This might be changed to a proper registry in the future KNOWN_STORAGE_TRANSFORMERS = [DummyStorageTransfomer, ShardingStorageTransformer] diff --git a/zarr/tests/test_attrs.py b/zarr/tests/test_attrs.py index 7dd5b340a2..a5ce4bac89 100644 --- a/zarr/tests/test_attrs.py +++ b/zarr/tests/test_attrs.py @@ -8,7 +8,7 @@ from zarr.attrs import Attributes from zarr.storage import KVStore, DirectoryStore from zarr._storage.v3 import KVStoreV3 -from zarr.tests.util import CountingDict, CountingDictV3 +from .util import CountingDict, CountingDictV3 from zarr.hierarchy import group diff --git a/zarr/tests/test_convenience.py b/zarr/tests/test_convenience.py index 389ce90a9d..0970a9e1aa 100644 --- a/zarr/tests/test_convenience.py +++ b/zarr/tests/test_convenience.py @@ -43,7 +43,7 @@ MemoryStoreV3, SQLiteStoreV3, ) -from zarr.tests.util import have_fsspec +from .util import have_fsspec _VERSIONS = (2, 3) if v3_api_available else (2,) diff --git a/zarr/tests/test_core.py b/zarr/tests/test_core.py index f3ca73dea8..c5a43ed39d 100644 --- a/zarr/tests/test_core.py +++ b/zarr/tests/test_core.py @@ -35,7 +35,11 @@ BaseStore, v3_api_available, ) -from .._storage.v3_storage_transformers import ShardingStorageTransformer, v3_sharding_available +from .._storage.v3_storage_transformers import ( + DummyStorageTransfomer, + ShardingStorageTransformer, + v3_sharding_available, +) from zarr.core import Array from zarr.errors import ArrayNotFoundError, ContainsGroupError from zarr.meta import json_loads @@ -70,9 +74,9 @@ SQLiteStoreV3, StoreV3, ) -from zarr.tests.test_storage_v3 import DummyStorageTransfomer + from zarr.util import buffer_size -from zarr.tests.util import abs_container, skip_test_env_var, have_fsspec, mktemp +from .util import abs_container, skip_test_env_var, have_fsspec, mktemp # noinspection PyMethodMayBeStatic diff --git a/zarr/tests/test_creation.py b/zarr/tests/test_creation.py index b44c6379fd..9307b81b52 100644 --- a/zarr/tests/test_creation.py +++ b/zarr/tests/test_creation.py @@ -8,6 +8,7 @@ from numpy.testing import assert_array_equal from zarr._storage.store import DEFAULT_ZARR_VERSION +from zarr._storage.v3_storage_transformers import DummyStorageTransfomer from zarr.codecs import Zlib from zarr.core import Array from zarr.creation import ( @@ -30,8 +31,7 @@ from zarr._storage.store import v3_api_available from zarr._storage.v3 import DirectoryStoreV3, KVStoreV3 from zarr.sync import ThreadSynchronizer -from zarr.tests.test_storage_v3 import DummyStorageTransfomer -from zarr.tests.util import mktemp, have_fsspec +from .util import mktemp, have_fsspec _VERSIONS = (None, 2, 3) if v3_api_available else (None, 2) diff --git a/zarr/tests/test_dim_separator.py b/zarr/tests/test_dim_separator.py index 987852dfd0..83f4d3b5b9 100644 --- a/zarr/tests/test_dim_separator.py +++ b/zarr/tests/test_dim_separator.py @@ -7,7 +7,7 @@ import zarr from zarr.core import Array from zarr.storage import DirectoryStore, NestedDirectoryStore, FSStore -from zarr.tests.util import have_fsspec +from .util import have_fsspec needs_fsspec = pytest.mark.skipif(not have_fsspec, reason="needs fsspec") diff --git a/zarr/tests/test_hierarchy.py b/zarr/tests/test_hierarchy.py index cbf59c55c3..3eaa4743dd 100644 --- a/zarr/tests/test_hierarchy.py +++ b/zarr/tests/test_hierarchy.py @@ -57,7 +57,7 @@ LRUStoreCacheV3, ) from zarr.util import InfoReporter, buffer_size -from zarr.tests.util import skip_test_env_var, have_fsspec, abs_container, mktemp +from .util import skip_test_env_var, have_fsspec, abs_container, mktemp _VERSIONS = (2, 3) if v3_api_available else (2,) diff --git a/zarr/tests/test_indexing.py b/zarr/tests/test_indexing.py index 8a34c1e715..1835206819 100644 --- a/zarr/tests/test_indexing.py +++ b/zarr/tests/test_indexing.py @@ -13,7 +13,7 @@ PartialChunkIterator, ) -from zarr.tests.util import CountingDict +from .util import CountingDict def test_normalize_integer_selection(): diff --git a/zarr/tests/test_n5.py b/zarr/tests/test_n5.py index 2602aa06c1..755d60b607 100644 --- a/zarr/tests/test_n5.py +++ b/zarr/tests/test_n5.py @@ -9,7 +9,7 @@ import json import atexit -from zarr.tests.util import have_fsspec +from .util import have_fsspec def test_make_n5_chunk_wrapper(): diff --git a/zarr/tests/test_storage.py b/zarr/tests/test_storage.py index e87716fa47..5c1d437ecb 100644 --- a/zarr/tests/test_storage.py +++ b/zarr/tests/test_storage.py @@ -59,7 +59,7 @@ ) from zarr.storage import FSStore, rename, listdir from zarr._storage.v3 import KVStoreV3 -from zarr.tests.util import CountingDict, have_fsspec, skip_test_env_var, abs_container, mktemp +from .util import CountingDict, have_fsspec, skip_test_env_var, abs_container, mktemp from zarr.util import ConstantMap, json_dumps diff --git a/zarr/tests/test_storage_v3.py b/zarr/tests/test_storage_v3.py index ded9296059..aeb4fe7d1b 100644 --- a/zarr/tests/test_storage_v3.py +++ b/zarr/tests/test_storage_v3.py @@ -10,7 +10,11 @@ import zarr from zarr._storage.store import _get_hierarchy_metadata, v3_api_available, StorageTransformer -from zarr._storage.v3_storage_transformers import ShardingStorageTransformer, v3_sharding_available +from zarr._storage.v3_storage_transformers import ( + DummyStorageTransfomer, + ShardingStorageTransformer, + v3_sharding_available, +) from zarr.core import Array from zarr.meta import _default_entry_point_metadata_v3 from zarr.storage import ( @@ -40,7 +44,7 @@ StoreV3, ZipStoreV3, ) -from zarr.tests.util import CountingDictV3, have_fsspec, skip_test_env_var, mktemp +from .util import CountingDictV3, have_fsspec, skip_test_env_var, mktemp # pytest will fail to run if the following fixtures aren't imported here from .test_storage import StoreTests as _StoreTests @@ -108,18 +112,6 @@ def keys(self): """keys""" -class DummyStorageTransfomer(StorageTransformer): - TEST_CONSTANT = "test1234" - - extension_uri = "https://purl.org/zarr/spec/storage_transformers/dummy/1.0" - valid_types = ["dummy_type"] - - def __init__(self, _type, test_value) -> None: - super().__init__(_type) - assert test_value == self.TEST_CONSTANT - self.test_value = test_value - - def test_ensure_store_v3(): class InvalidStore: pass diff --git a/zarr/tests/test_sync.py b/zarr/tests/test_sync.py index c28f6b081d..d066a4e8d6 100644 --- a/zarr/tests/test_sync.py +++ b/zarr/tests/test_sync.py @@ -16,9 +16,9 @@ from zarr.sync import ProcessSynchronizer, ThreadSynchronizer # zarr_version fixture must be imported although not used directly here -from zarr.tests.test_attrs import TestAttributes, zarr_version # noqa -from zarr.tests.test_core import TestArray -from zarr.tests.test_hierarchy import TestGroup +from .test_attrs import TestAttributes, zarr_version # noqa +from .test_core import TestArray +from .test_hierarchy import TestGroup class TestAttributesWithThreadSynchronizer(TestAttributes):