Skip to content

Commit 53b9faf

Browse files
authored
Merge branch 'main' into fix/open-v2-array-remotestore
2 parents fb52a7c + 680142f commit 53b9faf

40 files changed

+348
-253
lines changed

.github/workflows/releases.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
with:
5656
name: releases
5757
path: dist
58-
- uses: pypa/gh-action-pypi-publish@v1.10.3
58+
- uses: pypa/gh-action-pypi-publish@v1.11.0
5959
with:
6060
user: __token__
6161
password: ${{ secrets.pypi_password }}

.github/workflows/test.yml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,14 @@ jobs:
3333
numpy-version: '2.1'
3434
dependency-set: 'optional'
3535
os: 'macos-latest'
36-
# https://github.com/zarr-developers/zarr-python/issues/2438
37-
# - python-version: '3.11'
38-
# numpy-version: '1.25'
39-
# dependency-set: 'optional'
40-
# os: 'windows-latest'
41-
# - python-version: '3.13'
42-
# numpy-version: '2.1'
43-
# dependency-set: 'optional'
44-
# os: 'windows-latest'
36+
- python-version: '3.11'
37+
numpy-version: '1.25'
38+
dependency-set: 'optional'
39+
os: 'windows-latest'
40+
- python-version: '3.13'
41+
numpy-version: '2.1'
42+
dependency-set: 'optional'
43+
os: 'windows-latest'
4544
runs-on: ${{ matrix.os }}
4645

4746
steps:

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ default_language_version:
77
python: python3
88
repos:
99
- repo: https://github.com/astral-sh/ruff-pre-commit
10-
rev: v0.7.1
10+
rev: v0.7.2
1111
hooks:
1212
- id: ruff
1313
args: ["--fix", "--show-fixes"]

pyproject.toml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,19 +269,25 @@ extend-exclude = [
269269
extend-select = [
270270
"ANN", # flake8-annotations
271271
"B", # flake8-bugbear
272+
"EXE", # flake8-executable
272273
"C4", # flake8-comprehensions
274+
"FA", # flake8-future-annotations
273275
"FLY", # flynt
274276
"FURB", # refurb
275277
"G", # flake8-logging-format
276278
"I", # isort
277279
"ISC", # flake8-implicit-str-concat
280+
"LOG", # flake8-logging
278281
"PERF", # Perflint
282+
"PIE", # flake8-pie
279283
"PGH", # pygrep-hooks
280284
"PT", # flake8-pytest-style
281285
"PYI", # flake8-pyi
282-
"RSE", # flake8-raise
283286
"RET", # flake8-return
287+
"RSE", # flake8-raise
284288
"RUF",
289+
"SIM", # flake8-simplify
290+
"SLOT", # flake8-slots
285291
"TCH", # flake8-type-checking
286292
"TRY", # tryceratops
287293
"UP", # pyupgrade
@@ -298,6 +304,7 @@ ignore = [
298304
"RET505",
299305
"RET506",
300306
"RUF005",
307+
"SIM108",
301308
"TRY003",
302309
"UP027", # deprecated
303310
"UP038", # https://github.com/astral-sh/ruff/issues/7871
@@ -319,7 +326,7 @@ ignore = [
319326
]
320327

321328
[tool.ruff.lint.extend-per-file-ignores]
322-
"tests/**" = ["ANN001", "ANN201"]
329+
"tests/**" = ["ANN001", "ANN201", "RUF029", "SIM117", "SIM300"]
323330

324331
[tool.mypy]
325332
python_version = "3.11"

src/zarr/abc/codec.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ def validate(self, *, shape: ChunkCoords, dtype: np.dtype[Any], chunk_grid: Chun
106106
chunk_grid : ChunkGrid
107107
The array chunk grid
108108
"""
109-
...
110109

111110
async def _decode_single(self, chunk_data: CodecOutput, chunk_spec: ArraySpec) -> CodecInput:
112111
raise NotImplementedError

src/zarr/abc/metadata.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,5 @@ def from_dict(cls, data: dict[str, JSON]) -> Self:
4242
"""
4343
Create an instance of the model from a dictionary
4444
"""
45-
...
4645

4746
return cls(**data)

src/zarr/abc/store.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,6 @@ async def _set_many(self, values: Iterable[tuple[str, Buffer]]) -> None:
284284
Insert multiple (key, value) pairs into storage.
285285
"""
286286
await gather(*starmap(self.set, values))
287-
return
288287

289288
@property
290289
@abstractmethod
@@ -330,20 +329,19 @@ def supports_listing(self) -> bool:
330329
...
331330

332331
@abstractmethod
333-
def list(self) -> AsyncGenerator[str, None]:
332+
def list(self) -> AsyncGenerator[str]:
334333
"""Retrieve all keys in the store.
335334
336335
Returns
337336
-------
338337
AsyncGenerator[str, None]
339338
"""
340-
...
341339

342340
@abstractmethod
343-
def list_prefix(self, prefix: str) -> AsyncGenerator[str, None]:
341+
def list_prefix(self, prefix: str) -> AsyncGenerator[str]:
344342
"""
345-
Retrieve all keys in the store that begin with a given prefix. Keys are returned with the
346-
common leading prefix removed.
343+
Retrieve all keys in the store that begin with a given prefix. Keys are returned relative
344+
to the root of the store.
347345
348346
Parameters
349347
----------
@@ -353,10 +351,9 @@ def list_prefix(self, prefix: str) -> AsyncGenerator[str, None]:
353351
-------
354352
AsyncGenerator[str, None]
355353
"""
356-
...
357354

358355
@abstractmethod
359-
def list_dir(self, prefix: str) -> AsyncGenerator[str, None]:
356+
def list_dir(self, prefix: str) -> AsyncGenerator[str]:
360357
"""
361358
Retrieve all keys and prefixes with a given prefix and which do not contain the character
362359
“/” after the given prefix.
@@ -369,7 +366,20 @@ def list_dir(self, prefix: str) -> AsyncGenerator[str, None]:
369366
-------
370367
AsyncGenerator[str, None]
371368
"""
372-
...
369+
370+
async def delete_dir(self, prefix: str) -> None:
371+
"""
372+
Remove all keys and prefixes in the store that begin with a given prefix.
373+
"""
374+
if not self.supports_deletes:
375+
raise NotImplementedError
376+
if not self.supports_listing:
377+
raise NotImplementedError
378+
self._check_writable()
379+
if not prefix.endswith("/"):
380+
prefix += "/"
381+
async for key in self.list_prefix(prefix):
382+
await self.delete(key)
373383

374384
def close(self) -> None:
375385
"""Close the store."""

src/zarr/api/asynchronous.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
from zarr.abc.store import Store
1212
from zarr.core.array import Array, AsyncArray, get_array_metadata
13+
from zarr.core.buffer import NDArrayLike
1314
from zarr.core.common import (
1415
JSON,
1516
AccessModeLiteral,
@@ -31,7 +32,6 @@
3132
from collections.abc import Iterable
3233

3334
from zarr.abc.codec import Codec
34-
from zarr.core.buffer import NDArrayLike
3535
from zarr.core.chunk_key_encodings import ChunkKeyEncoding
3636

3737
# TODO: this type could use some more thought
@@ -390,6 +390,8 @@ async def save_array(
390390
_handle_zarr_version_or_format(zarr_version=zarr_version, zarr_format=zarr_format)
391391
or _default_zarr_version()
392392
)
393+
if not isinstance(arr, NDArrayLike):
394+
raise TypeError("arr argument must be numpy or other NDArrayLike array")
393395

394396
mode = kwargs.pop("mode", None)
395397
store_path = await make_store_path(store, path=path, mode=mode, storage_options=storage_options)
@@ -444,16 +446,26 @@ async def save_group(
444446
or _default_zarr_version()
445447
)
446448

449+
for arg in args:
450+
if not isinstance(arg, NDArrayLike):
451+
raise TypeError(
452+
"All arguments must be numpy or other NDArrayLike arrays (except store, path, storage_options, and zarr_format)"
453+
)
454+
for k, v in kwargs.items():
455+
if not isinstance(v, NDArrayLike):
456+
raise TypeError(f"Keyword argument '{k}' must be a numpy or other NDArrayLike array")
457+
447458
if len(args) == 0 and len(kwargs) == 0:
448459
raise ValueError("at least one array must be provided")
449460
aws = []
450461
for i, arr in enumerate(args):
462+
_path = f"{path}/arr_{i}" if path is not None else f"arr_{i}"
451463
aws.append(
452464
save_array(
453465
store,
454466
arr,
455467
zarr_format=zarr_format,
456-
path=f"{path}/arr_{i}",
468+
path=_path,
457469
storage_options=storage_options,
458470
)
459471
)
@@ -865,9 +877,8 @@ async def create(
865877
warnings.warn("meta_array is not yet implemented", RuntimeWarning, stacklevel=2)
866878

867879
mode = kwargs.pop("mode", None)
868-
if mode is None:
869-
if not isinstance(store, Store | StorePath):
870-
mode = "a"
880+
if mode is None and not isinstance(store, Store | StorePath):
881+
mode = "a"
871882

872883
store_path = await make_store_path(store, path=path, mode=mode, storage_options=storage_options)
873884

src/zarr/codecs/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,13 @@
99
from zarr.codecs.bytes import BytesCodec, Endian
1010
from zarr.codecs.crc32c_ import Crc32cCodec
1111
from zarr.codecs.gzip import GzipCodec
12-
from zarr.codecs.pipeline import BatchedCodecPipeline
1312
from zarr.codecs.sharding import ShardingCodec, ShardingCodecIndexLocation
1413
from zarr.codecs.transpose import TransposeCodec
1514
from zarr.codecs.vlen_utf8 import VLenBytesCodec, VLenUTF8Codec
1615
from zarr.codecs.zstd import ZstdCodec
1716
from zarr.core.metadata.v3 import DataType
1817

1918
__all__ = [
20-
"BatchedCodecPipeline",
2119
"BloscCname",
2220
"BloscCodec",
2321
"BloscShuffle",

src/zarr/codecs/gzip.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
def parse_gzip_level(data: JSON) -> int:
2222
if not isinstance(data, (int)):
2323
raise TypeError(f"Expected int, got {type(data)}")
24-
if data not in range(0, 10):
24+
if data not in range(10):
2525
raise ValueError(
2626
f"Expected an integer from the inclusive range (0, 9). Got {data} instead."
2727
)

0 commit comments

Comments
 (0)