Skip to content

Commit

Permalink
src layout + migrate to hatch
Browse files Browse the repository at this point in the history
  • Loading branch information
Saransh-cpp committed Jan 26, 2024
1 parent 1a98886 commit 4577ed3
Show file tree
Hide file tree
Showing 84 changed files with 150 additions and 34 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ target/
# Jupyter
.ipynb_checkpoints/

# setuptools-scm
zarr/version.py
# VCS versioning
src/zarr/_version.py

# emacs
*~
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ repos:
rev: v1.7.1
hooks:
- id: mypy
files: zarr
files: src
args: []
additional_dependencies:
- types-redis
Expand Down
2 changes: 1 addition & 1 deletion docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 6 additions & 11 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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]
Expand Down Expand Up @@ -35,7 +35,7 @@ classifiers = [
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
]
license = { text = "MIT" }
license = "MIT"

[project.optional-dependencies]
jupyter = [
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/fixture/.zgroup
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"zarr_format": 2
}
23 changes: 23 additions & 0 deletions src/fixture/flat/.zarray
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"chunks": [
2,
2
],
"compressor": {
"blocksize": 0,
"clevel": 5,
"cname": "lz4",
"id": "blosc",
"shuffle": 1
},
"dimension_separator": ".",
"dtype": "<i8",
"fill_value": 0,
"filters": null,
"order": "C",
"shape": [
2,
2
],
"zarr_format": 2
}
Binary file added src/fixture/flat/0.0
Binary file not shown.
22 changes: 22 additions & 0 deletions src/fixture/flat_legacy/.zarray
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"chunks": [
2,
2
],
"compressor": {
"blocksize": 0,
"clevel": 5,
"cname": "lz4",
"id": "blosc",
"shuffle": 1
},
"dtype": "<i8",
"fill_value": 0,
"filters": null,
"order": "C",
"shape": [
2,
2
],
"zarr_format": 2
}
Binary file added src/fixture/flat_legacy/0.0
Binary file not shown.
23 changes: 23 additions & 0 deletions src/fixture/meta/.zarray
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"chunks": [
2,
2
],
"compressor": {
"blocksize": 0,
"clevel": 5,
"cname": "lz4",
"id": "blosc",
"shuffle": 1
},
"dimension_separator": ".",
"dtype": "<i8",
"fill_value": 0,
"filters": null,
"order": "C",
"shape": [
2,
2
],
"zarr_format": 2
}
Binary file added src/fixture/meta/0.0
Binary file not shown.
23 changes: 23 additions & 0 deletions src/fixture/nested/.zarray
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"chunks": [
2,
2
],
"compressor": {
"blocksize": 0,
"clevel": 5,
"cname": "lz4",
"id": "blosc",
"shuffle": 1
},
"dimension_separator": "/",
"dtype": "<i8",
"fill_value": 0,
"filters": null,
"order": "C",
"shape": [
2,
2
],
"zarr_format": 2
}
Binary file added src/fixture/nested/0/0
Binary file not shown.
23 changes: 23 additions & 0 deletions src/fixture/nested_legacy/.zarray
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"chunks": [
2,
2
],
"compressor": {
"blocksize": 0,
"clevel": 5,
"cname": "lz4",
"id": "blosc",
"shuffle": 1
},
"dimension_separator": "/",
"dtype": "<i8",
"fill_value": 0,
"filters": null,
"order": "C",
"shape": [
2,
2
],
"zarr_format": 2
}
Binary file added src/fixture/nested_legacy/0/0
Binary file not shown.
1 change: 1 addition & 0 deletions src/fixture/utf8attrs/.zattrs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"foo": "た"}
3 changes: 3 additions & 0 deletions src/fixture/utf8attrs/.zgroup
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"zarr_format": 2
}
2 changes: 1 addition & 1 deletion zarr/__init__.py → src/zarr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
ZipStore,
)
from zarr.sync import ProcessSynchronizer, ThreadSynchronizer
from zarr.version import version as __version__
from zarr._version import version as __version__

# in case setuptools scm screw up and find version to be 0.0.0
assert not __version__.startswith("0.0.0")
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion zarr/_storage/v3.py → src/zarr/_storage/v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -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: zarr.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:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion zarr/meta.py → src/zarr/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ def _encode_storage_transformer_metadata(

@classmethod
def _decode_storage_transformer_metadata(cls, meta: Mapping) -> "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
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion zarr/tests/test_attrs.py → tests/test_attrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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,)

Expand Down
6 changes: 3 additions & 3 deletions zarr/tests/test_core.py → tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions zarr/tests/test_creation.py → tests/test_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion zarr/tests/test_hierarchy.py → tests/test_hierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,)
Expand Down
2 changes: 1 addition & 1 deletion zarr/tests/test_indexing.py → tests/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
PartialChunkIterator,
)

from zarr.tests.util import CountingDict
from tests.util import CountingDict


def test_normalize_integer_selection():
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion zarr/tests/test_n5.py → tests/test_n5.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
2 changes: 1 addition & 1 deletion zarr/tests/test_storage.py → tests/test_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
2 changes: 1 addition & 1 deletion zarr/tests/test_storage_v3.py → tests/test_storage_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions zarr/tests/test_sync.py → tests/test_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 4577ed3

Please sign in to comment.