From 4577ed30b7df2ade424999b335ea79e858397ccd Mon Sep 17 00:00:00 2001 From: Saransh Chopra Date: Fri, 26 Jan 2024 19:02:37 +0100 Subject: [PATCH 1/5] src layout + migrate to hatch --- .gitignore | 4 +-- .pre-commit-config.yaml | 2 +- docs/contributing.rst | 2 +- pyproject.toml | 17 +++++-------- src/fixture/.zgroup | 3 +++ src/fixture/flat/.zarray | 23 ++++++++++++++++++ src/fixture/flat/0.0 | Bin 0 -> 48 bytes src/fixture/flat_legacy/.zarray | 22 +++++++++++++++++ src/fixture/flat_legacy/0.0 | Bin 0 -> 48 bytes src/fixture/meta/.zarray | 23 ++++++++++++++++++ src/fixture/meta/0.0 | Bin 0 -> 48 bytes src/fixture/nested/.zarray | 23 ++++++++++++++++++ src/fixture/nested/0/0 | Bin 0 -> 48 bytes src/fixture/nested_legacy/.zarray | 23 ++++++++++++++++++ src/fixture/nested_legacy/0/0 | Bin 0 -> 48 bytes src/fixture/utf8attrs/.zattrs | 1 + src/fixture/utf8attrs/.zgroup | 3 +++ {zarr => src/zarr}/__init__.py | 2 +- {zarr => src/zarr}/_storage/__init__.py | 0 {zarr => src/zarr}/_storage/absstore.py | 0 {zarr => src/zarr}/_storage/store.py | 0 {zarr => src/zarr}/_storage/v3.py | 2 +- .../zarr}/_storage/v3_storage_transformers.py | 0 {zarr => src/zarr}/attrs.py | 0 {zarr => src/zarr}/codecs.py | 0 {zarr => src/zarr}/context.py | 0 {zarr => src/zarr}/convenience.py | 0 {zarr => src/zarr}/core.py | 0 {zarr => src/zarr}/creation.py | 0 {zarr => src/zarr}/errors.py | 0 {zarr => src/zarr}/hierarchy.py | 0 {zarr => src/zarr}/indexing.py | 0 {zarr => src/zarr}/meta.py | 2 +- {zarr => src/zarr}/meta_v1.py | 0 {zarr => src/zarr}/n5.py | 0 {zarr => src/zarr}/storage.py | 0 {zarr => src/zarr}/sync.py | 0 {zarr => src/zarr}/util.py | 0 {zarr => src/zarr}/v3/__init__.py | 0 {zarr/tests => src/zarr/v3/abc}/__init__.py | 0 {zarr => src/zarr}/v3/abc/array.py | 0 {zarr => src/zarr}/v3/abc/codec.py | 0 {zarr => src/zarr}/v3/abc/group.py | 0 {zarr => src/zarr}/v3/abc/store.py | 0 {zarr => src/zarr}/v3/array.py | 0 {zarr => src/zarr}/v3/array_v2.py | 0 {zarr => src/zarr}/v3/codecs/__init__.py | 0 {zarr => src/zarr}/v3/codecs/blosc.py | 0 {zarr => src/zarr}/v3/codecs/bytes.py | 0 {zarr => src/zarr}/v3/codecs/crc32c_.py | 0 {zarr => src/zarr}/v3/codecs/gzip.py | 0 {zarr => src/zarr}/v3/codecs/registry.py | 0 {zarr => src/zarr}/v3/codecs/sharding.py | 0 {zarr => src/zarr}/v3/codecs/transpose.py | 0 {zarr => src/zarr}/v3/codecs/zstd.py | 0 {zarr => src/zarr}/v3/common.py | 0 {zarr => src/zarr}/v3/group.py | 0 {zarr => src/zarr}/v3/group_v2.py | 0 {zarr => src/zarr}/v3/indexing.py | 0 {zarr => src/zarr}/v3/metadata.py | 0 {zarr => src/zarr}/v3/store.py | 0 {zarr => src/zarr}/v3/sync.py | 0 {zarr/v3/abc => tests}/__init__.py | 0 {zarr/tests => tests}/conftest.py | 0 {zarr/tests => tests}/data/store.zip | Bin {zarr/tests => tests}/data/store/foo | 0 {zarr/tests => tests}/test_attrs.py | 2 +- {zarr/tests => tests}/test_codecs_v3.py | 0 {zarr/tests => tests}/test_convenience.py | 2 +- {zarr/tests => tests}/test_core.py | 6 ++--- {zarr/tests => tests}/test_creation.py | 4 +-- {zarr/tests => tests}/test_dim_separator.py | 2 +- {zarr/tests => tests}/test_filters.py | 0 {zarr/tests => tests}/test_hierarchy.py | 2 +- {zarr/tests => tests}/test_indexing.py | 2 +- {zarr/tests => tests}/test_info.py | 0 {zarr/tests => tests}/test_meta.py | 0 {zarr/tests => tests}/test_meta_array.py | 0 {zarr/tests => tests}/test_n5.py | 2 +- {zarr/tests => tests}/test_storage.py | 2 +- {zarr/tests => tests}/test_storage_v3.py | 2 +- {zarr/tests => tests}/test_sync.py | 6 ++--- {zarr/tests => tests}/test_util.py | 0 {zarr/tests => tests}/util.py | 0 84 files changed, 150 insertions(+), 34 deletions(-) create mode 100644 src/fixture/.zgroup create mode 100644 src/fixture/flat/.zarray create mode 100644 src/fixture/flat/0.0 create mode 100644 src/fixture/flat_legacy/.zarray create mode 100644 src/fixture/flat_legacy/0.0 create mode 100644 src/fixture/meta/.zarray create mode 100644 src/fixture/meta/0.0 create mode 100644 src/fixture/nested/.zarray create mode 100644 src/fixture/nested/0/0 create mode 100644 src/fixture/nested_legacy/.zarray create mode 100644 src/fixture/nested_legacy/0/0 create mode 100644 src/fixture/utf8attrs/.zattrs create mode 100644 src/fixture/utf8attrs/.zgroup rename {zarr => src/zarr}/__init__.py (96%) rename {zarr => src/zarr}/_storage/__init__.py (100%) rename {zarr => src/zarr}/_storage/absstore.py (100%) rename {zarr => src/zarr}/_storage/store.py (100%) rename {zarr => src/zarr}/_storage/v3.py (99%) rename {zarr => src/zarr}/_storage/v3_storage_transformers.py (100%) rename {zarr => src/zarr}/attrs.py (100%) rename {zarr => src/zarr}/codecs.py (100%) rename {zarr => src/zarr}/context.py (100%) rename {zarr => src/zarr}/convenience.py (100%) rename {zarr => src/zarr}/core.py (100%) rename {zarr => src/zarr}/creation.py (100%) rename {zarr => src/zarr}/errors.py (100%) rename {zarr => src/zarr}/hierarchy.py (100%) rename {zarr => src/zarr}/indexing.py (100%) rename {zarr => src/zarr}/meta.py (99%) rename {zarr => src/zarr}/meta_v1.py (100%) rename {zarr => src/zarr}/n5.py (100%) rename {zarr => src/zarr}/storage.py (100%) rename {zarr => src/zarr}/sync.py (100%) rename {zarr => src/zarr}/util.py (100%) rename {zarr => src/zarr}/v3/__init__.py (100%) rename {zarr/tests => src/zarr/v3/abc}/__init__.py (100%) rename {zarr => src/zarr}/v3/abc/array.py (100%) rename {zarr => src/zarr}/v3/abc/codec.py (100%) rename {zarr => src/zarr}/v3/abc/group.py (100%) rename {zarr => src/zarr}/v3/abc/store.py (100%) rename {zarr => src/zarr}/v3/array.py (100%) rename {zarr => src/zarr}/v3/array_v2.py (100%) rename {zarr => src/zarr}/v3/codecs/__init__.py (100%) rename {zarr => src/zarr}/v3/codecs/blosc.py (100%) rename {zarr => src/zarr}/v3/codecs/bytes.py (100%) rename {zarr => src/zarr}/v3/codecs/crc32c_.py (100%) rename {zarr => src/zarr}/v3/codecs/gzip.py (100%) rename {zarr => src/zarr}/v3/codecs/registry.py (100%) rename {zarr => src/zarr}/v3/codecs/sharding.py (100%) rename {zarr => src/zarr}/v3/codecs/transpose.py (100%) rename {zarr => src/zarr}/v3/codecs/zstd.py (100%) rename {zarr => src/zarr}/v3/common.py (100%) rename {zarr => src/zarr}/v3/group.py (100%) rename {zarr => src/zarr}/v3/group_v2.py (100%) rename {zarr => src/zarr}/v3/indexing.py (100%) rename {zarr => src/zarr}/v3/metadata.py (100%) rename {zarr => src/zarr}/v3/store.py (100%) rename {zarr => src/zarr}/v3/sync.py (100%) rename {zarr/v3/abc => tests}/__init__.py (100%) rename {zarr/tests => tests}/conftest.py (100%) rename {zarr/tests => tests}/data/store.zip (100%) rename {zarr/tests => tests}/data/store/foo (100%) rename {zarr/tests => tests}/test_attrs.py (99%) rename {zarr/tests => tests}/test_codecs_v3.py (100%) rename {zarr/tests => tests}/test_convenience.py (99%) rename {zarr/tests => tests}/test_core.py (99%) rename {zarr/tests => tests}/test_creation.py (99%) rename {zarr/tests => tests}/test_dim_separator.py (99%) rename {zarr/tests => tests}/test_filters.py (100%) rename {zarr/tests => tests}/test_hierarchy.py (99%) rename {zarr/tests => tests}/test_indexing.py (99%) rename {zarr/tests => tests}/test_info.py (100%) rename {zarr/tests => tests}/test_meta.py (100%) rename {zarr/tests => tests}/test_meta_array.py (100%) rename {zarr/tests => tests}/test_n5.py (97%) rename {zarr/tests => tests}/test_storage.py (99%) rename {zarr/tests => tests}/test_storage_v3.py (99%) rename {zarr/tests => tests}/test_sync.py (98%) rename {zarr/tests => tests}/test_util.py (100%) rename {zarr/tests => tests}/util.py (100%) diff --git a/.gitignore b/.gitignore index 7de405d8a0..53b6cd356d 100644 --- a/.gitignore +++ b/.gitignore @@ -62,8 +62,8 @@ target/ # Jupyter .ipynb_checkpoints/ -# setuptools-scm -zarr/version.py +# VCS versioning +src/zarr/_version.py # emacs *~ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a8ee599137..10aff8b4c6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -30,7 +30,7 @@ repos: rev: v1.7.1 hooks: - id: mypy - files: zarr + files: src args: [] additional_dependencies: - types-redis diff --git a/docs/contributing.rst b/docs/contributing.rst index 91606b7276..f97cc03e26 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -335,7 +335,7 @@ of the storage specification that is currently implemented is stored under the Note that the Zarr test suite includes a data fixture and tests to try and ensure that data format compatibility is not accidentally broken. See the -:func:`test_format_compatibility` function in the :mod:`zarr.tests.test_storage` module +:func:`test_format_compatibility` function in the :mod:`.tests.test_storage` module for details. When to make a release diff --git a/pyproject.toml b/pyproject.toml index 22ea19f28f..62d997edd6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [build-system] -requires = ["setuptools>=64.0.0", "setuptools-scm>1.5.4"] -build-backend = "setuptools.build_meta" +requires = ["hatchling", "hatch-vcs"] +build-backend = "hatchling.build" [project] @@ -35,7 +35,7 @@ classifiers = [ 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11', ] -license = { text = "MIT" } +license = "MIT" [project.optional-dependencies] jupyter = [ @@ -73,14 +73,9 @@ omit = [ "bench/compress_normal.py", ] -[tool.setuptools] -packages = ["zarr", "zarr._storage", "zarr.tests"] -license-files = ["LICENSE.txt"] - -[tool.setuptools_scm] -version_scheme = "guess-next-dev" -local_scheme = "dirty-tag" -write_to = "zarr/version.py" +[tool.hatch] +version.source = "vcs" +build.hooks.vcs.version-file = "src/zarr/_version.py" [tool.ruff] line-length = 100 diff --git a/src/fixture/.zgroup b/src/fixture/.zgroup new file mode 100644 index 0000000000..3b7daf227c --- /dev/null +++ b/src/fixture/.zgroup @@ -0,0 +1,3 @@ +{ + "zarr_format": 2 +} \ No newline at end of file diff --git a/src/fixture/flat/.zarray b/src/fixture/flat/.zarray new file mode 100644 index 0000000000..d1acce7665 --- /dev/null +++ b/src/fixture/flat/.zarray @@ -0,0 +1,23 @@ +{ + "chunks": [ + 2, + 2 + ], + "compressor": { + "blocksize": 0, + "clevel": 5, + "cname": "lz4", + "id": "blosc", + "shuffle": 1 + }, + "dimension_separator": ".", + "dtype": " "StorageTransformer": - from zarr.tests.test_storage_v3 import DummyStorageTransfomer + from tests.test_storage_v3 import DummyStorageTransfomer from zarr._storage.v3_storage_transformers import ShardingStorageTransformer # This might be changed to a proper registry in the future diff --git a/zarr/meta_v1.py b/src/zarr/meta_v1.py similarity index 100% rename from zarr/meta_v1.py rename to src/zarr/meta_v1.py diff --git a/zarr/n5.py b/src/zarr/n5.py similarity index 100% rename from zarr/n5.py rename to src/zarr/n5.py diff --git a/zarr/storage.py b/src/zarr/storage.py similarity index 100% rename from zarr/storage.py rename to src/zarr/storage.py diff --git a/zarr/sync.py b/src/zarr/sync.py similarity index 100% rename from zarr/sync.py rename to src/zarr/sync.py diff --git a/zarr/util.py b/src/zarr/util.py similarity index 100% rename from zarr/util.py rename to src/zarr/util.py diff --git a/zarr/v3/__init__.py b/src/zarr/v3/__init__.py similarity index 100% rename from zarr/v3/__init__.py rename to src/zarr/v3/__init__.py diff --git a/zarr/tests/__init__.py b/src/zarr/v3/abc/__init__.py similarity index 100% rename from zarr/tests/__init__.py rename to src/zarr/v3/abc/__init__.py diff --git a/zarr/v3/abc/array.py b/src/zarr/v3/abc/array.py similarity index 100% rename from zarr/v3/abc/array.py rename to src/zarr/v3/abc/array.py diff --git a/zarr/v3/abc/codec.py b/src/zarr/v3/abc/codec.py similarity index 100% rename from zarr/v3/abc/codec.py rename to src/zarr/v3/abc/codec.py diff --git a/zarr/v3/abc/group.py b/src/zarr/v3/abc/group.py similarity index 100% rename from zarr/v3/abc/group.py rename to src/zarr/v3/abc/group.py diff --git a/zarr/v3/abc/store.py b/src/zarr/v3/abc/store.py similarity index 100% rename from zarr/v3/abc/store.py rename to src/zarr/v3/abc/store.py diff --git a/zarr/v3/array.py b/src/zarr/v3/array.py similarity index 100% rename from zarr/v3/array.py rename to src/zarr/v3/array.py diff --git a/zarr/v3/array_v2.py b/src/zarr/v3/array_v2.py similarity index 100% rename from zarr/v3/array_v2.py rename to src/zarr/v3/array_v2.py diff --git a/zarr/v3/codecs/__init__.py b/src/zarr/v3/codecs/__init__.py similarity index 100% rename from zarr/v3/codecs/__init__.py rename to src/zarr/v3/codecs/__init__.py diff --git a/zarr/v3/codecs/blosc.py b/src/zarr/v3/codecs/blosc.py similarity index 100% rename from zarr/v3/codecs/blosc.py rename to src/zarr/v3/codecs/blosc.py diff --git a/zarr/v3/codecs/bytes.py b/src/zarr/v3/codecs/bytes.py similarity index 100% rename from zarr/v3/codecs/bytes.py rename to src/zarr/v3/codecs/bytes.py diff --git a/zarr/v3/codecs/crc32c_.py b/src/zarr/v3/codecs/crc32c_.py similarity index 100% rename from zarr/v3/codecs/crc32c_.py rename to src/zarr/v3/codecs/crc32c_.py diff --git a/zarr/v3/codecs/gzip.py b/src/zarr/v3/codecs/gzip.py similarity index 100% rename from zarr/v3/codecs/gzip.py rename to src/zarr/v3/codecs/gzip.py diff --git a/zarr/v3/codecs/registry.py b/src/zarr/v3/codecs/registry.py similarity index 100% rename from zarr/v3/codecs/registry.py rename to src/zarr/v3/codecs/registry.py diff --git a/zarr/v3/codecs/sharding.py b/src/zarr/v3/codecs/sharding.py similarity index 100% rename from zarr/v3/codecs/sharding.py rename to src/zarr/v3/codecs/sharding.py diff --git a/zarr/v3/codecs/transpose.py b/src/zarr/v3/codecs/transpose.py similarity index 100% rename from zarr/v3/codecs/transpose.py rename to src/zarr/v3/codecs/transpose.py diff --git a/zarr/v3/codecs/zstd.py b/src/zarr/v3/codecs/zstd.py similarity index 100% rename from zarr/v3/codecs/zstd.py rename to src/zarr/v3/codecs/zstd.py diff --git a/zarr/v3/common.py b/src/zarr/v3/common.py similarity index 100% rename from zarr/v3/common.py rename to src/zarr/v3/common.py diff --git a/zarr/v3/group.py b/src/zarr/v3/group.py similarity index 100% rename from zarr/v3/group.py rename to src/zarr/v3/group.py diff --git a/zarr/v3/group_v2.py b/src/zarr/v3/group_v2.py similarity index 100% rename from zarr/v3/group_v2.py rename to src/zarr/v3/group_v2.py diff --git a/zarr/v3/indexing.py b/src/zarr/v3/indexing.py similarity index 100% rename from zarr/v3/indexing.py rename to src/zarr/v3/indexing.py diff --git a/zarr/v3/metadata.py b/src/zarr/v3/metadata.py similarity index 100% rename from zarr/v3/metadata.py rename to src/zarr/v3/metadata.py diff --git a/zarr/v3/store.py b/src/zarr/v3/store.py similarity index 100% rename from zarr/v3/store.py rename to src/zarr/v3/store.py diff --git a/zarr/v3/sync.py b/src/zarr/v3/sync.py similarity index 100% rename from zarr/v3/sync.py rename to src/zarr/v3/sync.py diff --git a/zarr/v3/abc/__init__.py b/tests/__init__.py similarity index 100% rename from zarr/v3/abc/__init__.py rename to tests/__init__.py diff --git a/zarr/tests/conftest.py b/tests/conftest.py similarity index 100% rename from zarr/tests/conftest.py rename to tests/conftest.py diff --git a/zarr/tests/data/store.zip b/tests/data/store.zip similarity index 100% rename from zarr/tests/data/store.zip rename to tests/data/store.zip diff --git a/zarr/tests/data/store/foo b/tests/data/store/foo similarity index 100% rename from zarr/tests/data/store/foo rename to tests/data/store/foo diff --git a/zarr/tests/test_attrs.py b/tests/test_attrs.py similarity index 99% rename from zarr/tests/test_attrs.py rename to tests/test_attrs.py index 7dd5b340a2..ff2b251d01 100644 --- a/zarr/tests/test_attrs.py +++ b/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 tests.util import CountingDict, CountingDictV3 from zarr.hierarchy import group diff --git a/zarr/tests/test_codecs_v3.py b/tests/test_codecs_v3.py similarity index 100% rename from zarr/tests/test_codecs_v3.py rename to tests/test_codecs_v3.py diff --git a/zarr/tests/test_convenience.py b/tests/test_convenience.py similarity index 99% rename from zarr/tests/test_convenience.py rename to tests/test_convenience.py index 389ce90a9d..e883a2d25a 100644 --- a/zarr/tests/test_convenience.py +++ b/tests/test_convenience.py @@ -43,7 +43,7 @@ MemoryStoreV3, SQLiteStoreV3, ) -from zarr.tests.util import have_fsspec +from tests.util import have_fsspec _VERSIONS = (2, 3) if v3_api_available else (2,) diff --git a/zarr/tests/test_core.py b/tests/test_core.py similarity index 99% rename from zarr/tests/test_core.py rename to tests/test_core.py index f3ca73dea8..c099b92027 100644 --- a/zarr/tests/test_core.py +++ b/tests/test_core.py @@ -35,7 +35,7 @@ BaseStore, v3_api_available, ) -from .._storage.v3_storage_transformers import ShardingStorageTransformer, v3_sharding_available +from zarr._storage.v3_storage_transformers import ShardingStorageTransformer, v3_sharding_available from zarr.core import Array from zarr.errors import ArrayNotFoundError, ContainsGroupError from zarr.meta import json_loads @@ -70,9 +70,9 @@ SQLiteStoreV3, StoreV3, ) -from zarr.tests.test_storage_v3 import DummyStorageTransfomer +from 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 tests.util import abs_container, skip_test_env_var, have_fsspec, mktemp # noinspection PyMethodMayBeStatic diff --git a/zarr/tests/test_creation.py b/tests/test_creation.py similarity index 99% rename from zarr/tests/test_creation.py rename to tests/test_creation.py index b44c6379fd..c5dfbc7fe2 100644 --- a/zarr/tests/test_creation.py +++ b/tests/test_creation.py @@ -30,8 +30,8 @@ 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 tests.test_storage_v3 import DummyStorageTransfomer +from tests.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/tests/test_dim_separator.py similarity index 99% rename from zarr/tests/test_dim_separator.py rename to tests/test_dim_separator.py index 987852dfd0..89b73fbafa 100644 --- a/zarr/tests/test_dim_separator.py +++ b/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 tests.util import have_fsspec needs_fsspec = pytest.mark.skipif(not have_fsspec, reason="needs fsspec") diff --git a/zarr/tests/test_filters.py b/tests/test_filters.py similarity index 100% rename from zarr/tests/test_filters.py rename to tests/test_filters.py diff --git a/zarr/tests/test_hierarchy.py b/tests/test_hierarchy.py similarity index 99% rename from zarr/tests/test_hierarchy.py rename to tests/test_hierarchy.py index cbf59c55c3..58091b815e 100644 --- a/zarr/tests/test_hierarchy.py +++ b/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 tests.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/tests/test_indexing.py similarity index 99% rename from zarr/tests/test_indexing.py rename to tests/test_indexing.py index 8a34c1e715..7a4851ce4d 100644 --- a/zarr/tests/test_indexing.py +++ b/tests/test_indexing.py @@ -13,7 +13,7 @@ PartialChunkIterator, ) -from zarr.tests.util import CountingDict +from tests.util import CountingDict def test_normalize_integer_selection(): diff --git a/zarr/tests/test_info.py b/tests/test_info.py similarity index 100% rename from zarr/tests/test_info.py rename to tests/test_info.py diff --git a/zarr/tests/test_meta.py b/tests/test_meta.py similarity index 100% rename from zarr/tests/test_meta.py rename to tests/test_meta.py diff --git a/zarr/tests/test_meta_array.py b/tests/test_meta_array.py similarity index 100% rename from zarr/tests/test_meta_array.py rename to tests/test_meta_array.py diff --git a/zarr/tests/test_n5.py b/tests/test_n5.py similarity index 97% rename from zarr/tests/test_n5.py rename to tests/test_n5.py index 2602aa06c1..bd395c5a1e 100644 --- a/zarr/tests/test_n5.py +++ b/tests/test_n5.py @@ -9,7 +9,7 @@ import json import atexit -from zarr.tests.util import have_fsspec +from tests.util import have_fsspec def test_make_n5_chunk_wrapper(): diff --git a/zarr/tests/test_storage.py b/tests/test_storage.py similarity index 99% rename from zarr/tests/test_storage.py rename to tests/test_storage.py index e87716fa47..7c444d91fe 100644 --- a/zarr/tests/test_storage.py +++ b/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 tests.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/tests/test_storage_v3.py similarity index 99% rename from zarr/tests/test_storage_v3.py rename to tests/test_storage_v3.py index ded9296059..d2931878f3 100644 --- a/zarr/tests/test_storage_v3.py +++ b/tests/test_storage_v3.py @@ -40,7 +40,7 @@ StoreV3, ZipStoreV3, ) -from zarr.tests.util import CountingDictV3, have_fsspec, skip_test_env_var, mktemp +from tests.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 diff --git a/zarr/tests/test_sync.py b/tests/test_sync.py similarity index 98% rename from zarr/tests/test_sync.py rename to tests/test_sync.py index c28f6b081d..b0ddb7942f 100644 --- a/zarr/tests/test_sync.py +++ b/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 tests.test_attrs import TestAttributes, zarr_version # noqa +from tests.test_core import TestArray +from tests.test_hierarchy import TestGroup class TestAttributesWithThreadSynchronizer(TestAttributes): diff --git a/zarr/tests/test_util.py b/tests/test_util.py similarity index 100% rename from zarr/tests/test_util.py rename to tests/test_util.py diff --git a/zarr/tests/util.py b/tests/util.py similarity index 100% rename from zarr/tests/util.py rename to tests/util.py From a5981a351731695d98661a8d11aac7548beeafd9 Mon Sep 17 00:00:00 2001 From: Saransh Chopra Date: Fri, 26 Jan 2024 19:04:03 +0100 Subject: [PATCH 2/5] feat: git archival support --- .git_archival.txt | 4 ++++ .gitattributes | 1 + pyproject.toml | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .git_archival.txt diff --git a/.git_archival.txt b/.git_archival.txt new file mode 100644 index 0000000000..8fb235d704 --- /dev/null +++ b/.git_archival.txt @@ -0,0 +1,4 @@ +node: $Format:%H$ +node-date: $Format:%cI$ +describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$ +ref-names: $Format:%D$ diff --git a/.gitattributes b/.gitattributes index b6115e6e49..57eb8a8807 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,3 @@ *.py linguist-language=python *.ipynb linguist-documentation +.git_archival.txt export-subst diff --git a/pyproject.toml b/pyproject.toml index 62d997edd6..4eaaa1650a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -69,7 +69,7 @@ exclude_lines = [ [tool.coverage.run] omit = [ - "zarr/meta_v1.py", + "src/zarr/meta_v1.py", "bench/compress_normal.py", ] From 2e823a5bf939799936941ccb8aaa6a46e21badd7 Mon Sep 17 00:00:00 2001 From: Saransh Chopra Date: Fri, 26 Jan 2024 19:05:36 +0100 Subject: [PATCH 3/5] rm test generated files --- src/fixture/.zgroup | 3 --- src/fixture/flat/.zarray | 23 ----------------------- src/fixture/flat/0.0 | Bin 48 -> 0 bytes src/fixture/flat_legacy/.zarray | 22 ---------------------- src/fixture/flat_legacy/0.0 | Bin 48 -> 0 bytes src/fixture/meta/.zarray | 23 ----------------------- src/fixture/meta/0.0 | Bin 48 -> 0 bytes src/fixture/nested/.zarray | 23 ----------------------- src/fixture/nested/0/0 | Bin 48 -> 0 bytes src/fixture/nested_legacy/.zarray | 23 ----------------------- src/fixture/nested_legacy/0/0 | Bin 48 -> 0 bytes src/fixture/utf8attrs/.zattrs | 1 - src/fixture/utf8attrs/.zgroup | 3 --- 13 files changed, 121 deletions(-) delete mode 100644 src/fixture/.zgroup delete mode 100644 src/fixture/flat/.zarray delete mode 100644 src/fixture/flat/0.0 delete mode 100644 src/fixture/flat_legacy/.zarray delete mode 100644 src/fixture/flat_legacy/0.0 delete mode 100644 src/fixture/meta/.zarray delete mode 100644 src/fixture/meta/0.0 delete mode 100644 src/fixture/nested/.zarray delete mode 100644 src/fixture/nested/0/0 delete mode 100644 src/fixture/nested_legacy/.zarray delete mode 100644 src/fixture/nested_legacy/0/0 delete mode 100644 src/fixture/utf8attrs/.zattrs delete mode 100644 src/fixture/utf8attrs/.zgroup diff --git a/src/fixture/.zgroup b/src/fixture/.zgroup deleted file mode 100644 index 3b7daf227c..0000000000 --- a/src/fixture/.zgroup +++ /dev/null @@ -1,3 +0,0 @@ -{ - "zarr_format": 2 -} \ No newline at end of file diff --git a/src/fixture/flat/.zarray b/src/fixture/flat/.zarray deleted file mode 100644 index d1acce7665..0000000000 --- a/src/fixture/flat/.zarray +++ /dev/null @@ -1,23 +0,0 @@ -{ - "chunks": [ - 2, - 2 - ], - "compressor": { - "blocksize": 0, - "clevel": 5, - "cname": "lz4", - "id": "blosc", - "shuffle": 1 - }, - "dimension_separator": ".", - "dtype": " Date: Fri, 26 Jan 2024 19:07:18 +0100 Subject: [PATCH 4/5] Apply suggestions from code review --- docs/contributing.rst | 2 +- src/zarr/_storage/v3.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/contributing.rst b/docs/contributing.rst index f97cc03e26..a65b3d104d 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -335,7 +335,7 @@ of the storage specification that is currently implemented is stored under the Note that the Zarr test suite includes a data fixture and tests to try and ensure that data format compatibility is not accidentally broken. See the -:func:`test_format_compatibility` function in the :mod:`.tests.test_storage` module +:func:`test_format_compatibility` function in the :mod:`tests.test_storage` module for details. When to make a release diff --git a/src/zarr/_storage/v3.py b/src/zarr/_storage/v3.py index 290aae2d8d..8ab54984b7 100644 --- a/src/zarr/_storage/v3.py +++ b/src/zarr/_storage/v3.py @@ -163,7 +163,7 @@ def setitems(self, values): values = {self._normalize_key(key): val for key, val in values.items()} # initialize the /data/root/... folder corresponding to the array! - # Note: .tests.test_core_v3.TestArrayWithFSStoreV3PartialRead fails + # Note: tests.test_core_v3.TestArrayWithFSStoreV3PartialRead fails # without this explicit creation of directories subdirectories = set(os.path.dirname(v) for v in values.keys()) for subdirectory in subdirectories: From 3ec8164e2161c9f7766d6e96566c01141c5f87df Mon Sep 17 00:00:00 2001 From: Saransh Chopra Date: Sat, 3 Feb 2024 15:06:47 +0100 Subject: [PATCH 5/5] Use relative imports --- tests/test_attrs.py | 2 +- tests/test_convenience.py | 2 +- tests/test_core.py | 2 +- tests/test_creation.py | 2 +- tests/test_dim_separator.py | 2 +- tests/test_hierarchy.py | 2 +- tests/test_indexing.py | 2 +- tests/test_n5.py | 2 +- tests/test_storage.py | 2 +- tests/test_storage_v3.py | 2 +- tests/test_sync.py | 6 +++--- 11 files changed, 13 insertions(+), 13 deletions(-) diff --git a/tests/test_attrs.py b/tests/test_attrs.py index ff2b251d01..a5ce4bac89 100644 --- a/tests/test_attrs.py +++ b/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 tests.util import CountingDict, CountingDictV3 +from .util import CountingDict, CountingDictV3 from zarr.hierarchy import group diff --git a/tests/test_convenience.py b/tests/test_convenience.py index e883a2d25a..0970a9e1aa 100644 --- a/tests/test_convenience.py +++ b/tests/test_convenience.py @@ -43,7 +43,7 @@ MemoryStoreV3, SQLiteStoreV3, ) -from tests.util import have_fsspec +from .util import have_fsspec _VERSIONS = (2, 3) if v3_api_available else (2,) diff --git a/tests/test_core.py b/tests/test_core.py index 8b80874aa2..87bf72e9b0 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -76,7 +76,7 @@ ) from zarr.util import buffer_size -from 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/tests/test_creation.py b/tests/test_creation.py index 3b15654e3b..9307b81b52 100644 --- a/tests/test_creation.py +++ b/tests/test_creation.py @@ -31,7 +31,7 @@ from zarr._storage.store import v3_api_available from zarr._storage.v3 import DirectoryStoreV3, KVStoreV3 from zarr.sync import ThreadSynchronizer -from 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/tests/test_dim_separator.py b/tests/test_dim_separator.py index 89b73fbafa..83f4d3b5b9 100644 --- a/tests/test_dim_separator.py +++ b/tests/test_dim_separator.py @@ -7,7 +7,7 @@ import zarr from zarr.core import Array from zarr.storage import DirectoryStore, NestedDirectoryStore, FSStore -from tests.util import have_fsspec +from .util import have_fsspec needs_fsspec = pytest.mark.skipif(not have_fsspec, reason="needs fsspec") diff --git a/tests/test_hierarchy.py b/tests/test_hierarchy.py index 58091b815e..3eaa4743dd 100644 --- a/tests/test_hierarchy.py +++ b/tests/test_hierarchy.py @@ -57,7 +57,7 @@ LRUStoreCacheV3, ) from zarr.util import InfoReporter, buffer_size -from 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/tests/test_indexing.py b/tests/test_indexing.py index 7a4851ce4d..1835206819 100644 --- a/tests/test_indexing.py +++ b/tests/test_indexing.py @@ -13,7 +13,7 @@ PartialChunkIterator, ) -from tests.util import CountingDict +from .util import CountingDict def test_normalize_integer_selection(): diff --git a/tests/test_n5.py b/tests/test_n5.py index bd395c5a1e..755d60b607 100644 --- a/tests/test_n5.py +++ b/tests/test_n5.py @@ -9,7 +9,7 @@ import json import atexit -from tests.util import have_fsspec +from .util import have_fsspec def test_make_n5_chunk_wrapper(): diff --git a/tests/test_storage.py b/tests/test_storage.py index 7c444d91fe..5c1d437ecb 100644 --- a/tests/test_storage.py +++ b/tests/test_storage.py @@ -59,7 +59,7 @@ ) from zarr.storage import FSStore, rename, listdir from zarr._storage.v3 import KVStoreV3 -from 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/tests/test_storage_v3.py b/tests/test_storage_v3.py index 28071d691c..aeb4fe7d1b 100644 --- a/tests/test_storage_v3.py +++ b/tests/test_storage_v3.py @@ -44,7 +44,7 @@ StoreV3, ZipStoreV3, ) -from 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 diff --git a/tests/test_sync.py b/tests/test_sync.py index b0ddb7942f..d066a4e8d6 100644 --- a/tests/test_sync.py +++ b/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 tests.test_attrs import TestAttributes, zarr_version # noqa -from tests.test_core import TestArray -from 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):