Skip to content

Commit 002b805

Browse files
committed
deps: slim zarr dependencies
1 parent 1131253 commit 002b805

File tree

11 files changed

+30
-20
lines changed

11 files changed

+30
-20
lines changed

.pre-commit-config.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,14 @@ repos:
2828
files: src|tests
2929
additional_dependencies:
3030
# Package dependencies
31-
- asciitree
3231
- crc32c
3332
- donfig
34-
- fasteners
3533
- numcodecs
3634
- numpy
3735
- typing_extensions
3836
- universal-pathlib
3937
# Tests
4038
- pytest
41-
# Zarr v2
42-
- types-redis
4339
- repo: https://github.com/scientific-python/cookie
4440
rev: 2024.08.19
4541
hooks:

pyproject.toml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,8 @@ maintainers = [
2323
requires-python = ">=3.11"
2424
# If you add a new dependency here, please also add it to .pre-commit-config.yml
2525
dependencies = [
26-
'asciitree',
2726
'numpy>=1.25',
28-
'fasteners',
29-
'numcodecs>=0.10.2',
30-
'fsspec>2024',
31-
'crc32c',
27+
'numcodecs>=0.12',
3228
'typing_extensions',
3329
'donfig',
3430
]
@@ -52,17 +48,19 @@ license = {text = "MIT License"}
5248
keywords = ["Python", "compressed", "ndimensional-arrays", "zarr"]
5349

5450
[project.optional-dependencies]
51+
remote = [
52+
"fsspec",
53+
]
54+
sharding = [
55+
"crc32c",
56+
]
5557
test = [
5658
"coverage",
5759
"pytest",
5860
"pytest-cov",
59-
"msgpack",
60-
"lmdb",
6161
"s3fs",
6262
"pytest-asyncio",
6363
"moto[s3]",
64-
"flask-cors",
65-
"flask",
6664
"requests",
6765
"mypy",
6866
"hypothesis",

src/zarr/codecs/crc32c_.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import numpy as np
77
import typing_extensions
8-
from crc32c import crc32c
98

109
from zarr.abc.codec import BytesBytesCodec
1110
from zarr.core.common import JSON, parse_named_configuration
@@ -35,6 +34,8 @@ async def _decode_single(
3534
chunk_bytes: Buffer,
3635
chunk_spec: ArraySpec,
3736
) -> Buffer:
37+
from crc32c import crc32c
38+
3839
data = chunk_bytes.as_numpy_array()
3940
crc32_bytes = data[-4:]
4041
inner_bytes = data[:-4]
@@ -53,6 +54,8 @@ async def _encode_single(
5354
chunk_bytes: Buffer,
5455
chunk_spec: ArraySpec,
5556
) -> Buffer | None:
57+
from crc32c import crc32c
58+
5659
data = chunk_bytes.as_numpy_array()
5760
# Calculate the checksum and "cast" it to a numpy array
5861
checksum = np.array([crc32c(cast(typing_extensions.Buffer, data))], dtype=np.uint32)

src/zarr/storage/remote.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
from typing import TYPE_CHECKING, Any, Self
44

5-
import fsspec
6-
75
from zarr.abc.store import ByteRangeRequest, Store
86
from zarr.storage.common import _dereference_path
97

@@ -130,6 +128,8 @@ def from_url(
130128
-------
131129
RemoteStore
132130
"""
131+
import fsspec
132+
133133
fs, path = fsspec.url_to_fs(url, **storage_options)
134134
return cls(fs=fs, path=path, mode=mode, allowed_exceptions=allowed_exceptions)
135135

tests/v3/test_buffer.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ async def test_async_array_gpu_prototype() -> None:
9797

9898
@pytest.mark.asyncio
9999
async def test_codecs_use_of_prototype() -> None:
100+
pytest.importorskip("crc32c")
100101
expect = np.zeros((10, 10), dtype="uint16", order="F")
101102
a = await AsyncArray.create(
102103
StorePath(StoreExpectingTestBuffer(mode="w")) / "test_codecs_use_of_prototype",
@@ -132,6 +133,7 @@ async def test_codecs_use_of_prototype() -> None:
132133
@gpu_test
133134
@pytest.mark.asyncio
134135
async def test_codecs_use_of_gpu_prototype() -> None:
136+
pytest.importorskip("crc32c")
135137
expect = cp.zeros((10, 10), dtype="uint16", order="F")
136138
a = await AsyncArray.create(
137139
StorePath(MemoryStore(mode="w")) / "test_codecs_use_of_gpu_prototype",

tests/v3/test_codecs/test_codecs.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ async def test_order(
7373
runtime_read_order: MemoryOrder,
7474
with_sharding: bool,
7575
) -> None:
76+
if with_sharding:
77+
pytest.importorskip("crc32c")
7678
data = np.arange(0, 256, dtype="uint16").reshape((32, 8), order=input_order)
7779
path = "order"
7880
spath = StorePath(store, path=path)
@@ -129,6 +131,8 @@ def test_order_implicit(
129131
runtime_read_order: MemoryOrder,
130132
with_sharding: bool,
131133
) -> None:
134+
if with_sharding:
135+
pytest.importorskip("crc32c")
132136
data = np.arange(0, 256, dtype="uint16").reshape((16, 16), order=input_order)
133137
path = "order_implicit"
134138
spath = StorePath(store, path)

tests/v3/test_codecs/test_sharding.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
from ..conftest import ArrayRequest
2121
from .test_codecs import _AsyncArrayProxy, order_from_dim
2222

23+
pytest.importorskip("crc32c")
24+
2325

2426
@pytest.mark.parametrize("store", ["local", "memory", "zip"], indirect=["store"])
2527
@pytest.mark.parametrize("index_location", ["start", "end"])

tests/v3/test_codecs/test_transpose.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ async def test_transpose(
2727
runtime_read_order: MemoryOrder,
2828
with_sharding: bool,
2929
) -> None:
30+
if with_sharding:
31+
pytest.importorskip("crc32c")
3032
data = np.arange(0, 256, dtype="uint16").reshape((1, 32, 8), order=input_order)
3133
spath = StorePath(store, path="transpose")
3234
codecs_: list[Codec] = (

tests/v3/test_config.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,9 @@ def test_config_buffer_implementation() -> None:
215215
arr[:] = np.arange(100)
216216
assert np.array_equal(arr[:], data)
217217

218+
219+
def test_config_sharding_implementation() -> None:
220+
pytest.importorskip("crc32c")
218221
data2d = np.arange(1000).reshape(100, 10)
219222
arr_sharding = zeros(
220223
shape=(100, 10),

tests/v3/test_store/test_core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ async def test_make_store_path(tmpdir: str) -> None:
3939

4040

4141
async def test_make_store_path_fsspec(monkeypatch) -> None:
42-
import fsspec.implementations.memory
42+
fsspec = pytest.importorskip("fsspec")
4343

4444
monkeypatch.setattr(fsspec.implementations.memory.MemoryFileSystem, "async_impl", True)
4545
store_path = await make_store_path("memory://")

0 commit comments

Comments
 (0)