Skip to content

Commit 328e290

Browse files
authored
Merge branch 'main' into feat/latency-store
2 parents 12d3f75 + 01b73a7 commit 328e290

File tree

19 files changed

+106
-107
lines changed

19 files changed

+106
-107
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
ci:
22
autoupdate_commit_msg: "chore: update pre-commit hooks"
3+
autoupdate_schedule: "monthly"
34
autofix_commit_msg: "style: pre-commit fixes"
45
autofix_prs: false
56
default_stages: [pre-commit, pre-push]
6-
default_language_version:
7-
python: python3
87
repos:
98
- repo: https://github.com/astral-sh/ruff-pre-commit
109
rev: v0.8.2
@@ -16,7 +15,7 @@ repos:
1615
rev: v2.3.0
1716
hooks:
1817
- id: codespell
19-
args: ["-L", "ba,ihs,kake,nd,noe,nwo,te,fo,zar", "-S", "fixture"]
18+
args: ["-L", "fo,ihs,kake,te", "-S", "fixture"]
2019
- repo: https://github.com/pre-commit/pre-commit-hooks
2120
rev: v5.0.0
2221
hooks:

src/zarr/api/asynchronous.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
_OVERWRITE_MODES: tuple[AccessModeLiteral, ...] = ("a", "r+", "w")
7272

7373

74-
def _infer_exists_ok(mode: AccessModeLiteral) -> bool:
74+
def _infer_overwrite(mode: AccessModeLiteral) -> bool:
7575
"""
7676
Check that an ``AccessModeLiteral`` is compatible with overwriting an existing Zarr node.
7777
"""
@@ -414,14 +414,14 @@ async def save_array(
414414
arr = np.array(arr)
415415
shape = arr.shape
416416
chunks = getattr(arr, "chunks", None) # for array-likes with chunks attribute
417-
exists_ok = kwargs.pop("exists_ok", None) or _infer_exists_ok(mode)
417+
overwrite = kwargs.pop("overwrite", None) or _infer_overwrite(mode)
418418
new = await AsyncArray.create(
419419
store_path,
420420
zarr_format=zarr_format,
421421
shape=shape,
422422
dtype=arr.dtype,
423423
chunks=chunks,
424-
exists_ok=exists_ok,
424+
overwrite=overwrite,
425425
**kwargs,
426426
)
427427
await new.setitem(slice(None), arr)
@@ -647,7 +647,7 @@ async def group(
647647
return await AsyncGroup.from_store(
648648
store=store_path,
649649
zarr_format=_zarr_format,
650-
exists_ok=overwrite,
650+
overwrite=overwrite,
651651
attributes=attributes,
652652
)
653653

@@ -753,12 +753,12 @@ async def open_group(
753753
except (KeyError, FileNotFoundError):
754754
pass
755755
if mode in _CREATE_MODES:
756-
exists_ok = _infer_exists_ok(mode)
756+
overwrite = _infer_overwrite(mode)
757757
_zarr_format = zarr_format or _default_zarr_version()
758758
return await AsyncGroup.from_store(
759759
store_path,
760760
zarr_format=_zarr_format,
761-
exists_ok=exists_ok,
761+
overwrite=overwrite,
762762
attributes=attributes,
763763
)
764764
raise FileNotFoundError(f"Unable to find group: {store_path}")
@@ -933,7 +933,7 @@ async def create(
933933
dtype=dtype,
934934
compressor=compressor,
935935
fill_value=fill_value,
936-
exists_ok=overwrite,
936+
overwrite=overwrite,
937937
filters=filters,
938938
dimension_separator=dimension_separator,
939939
zarr_format=zarr_format,
@@ -1120,12 +1120,12 @@ async def open_array(
11201120
return await AsyncArray.open(store_path, zarr_format=zarr_format)
11211121
except FileNotFoundError:
11221122
if not store_path.read_only and mode in _CREATE_MODES:
1123-
exists_ok = _infer_exists_ok(mode)
1123+
overwrite = _infer_overwrite(mode)
11241124
_zarr_format = zarr_format or _default_zarr_version()
11251125
return await create(
11261126
store=store_path,
11271127
zarr_format=_zarr_format,
1128-
overwrite=exists_ok,
1128+
overwrite=overwrite,
11291129
**kwargs,
11301130
)
11311131
raise

src/zarr/core/array.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ async def create(
266266
filters: list[dict[str, JSON]] | None = None,
267267
compressor: dict[str, JSON] | None = None,
268268
# runtime
269-
exists_ok: bool = False,
269+
overwrite: bool = False,
270270
data: npt.ArrayLike | None = None,
271271
) -> AsyncArray[ArrayV2Metadata]: ...
272272

@@ -294,7 +294,7 @@ async def create(
294294
codecs: Iterable[Codec | dict[str, JSON]] | None = None,
295295
dimension_names: Iterable[str] | None = None,
296296
# runtime
297-
exists_ok: bool = False,
297+
overwrite: bool = False,
298298
data: npt.ArrayLike | None = None,
299299
) -> AsyncArray[ArrayV3Metadata]: ...
300300

@@ -322,7 +322,7 @@ async def create(
322322
codecs: Iterable[Codec | dict[str, JSON]] | None = None,
323323
dimension_names: Iterable[str] | None = None,
324324
# runtime
325-
exists_ok: bool = False,
325+
overwrite: bool = False,
326326
data: npt.ArrayLike | None = None,
327327
) -> AsyncArray[ArrayV3Metadata]: ...
328328

@@ -355,7 +355,7 @@ async def create(
355355
filters: list[dict[str, JSON]] | None = None,
356356
compressor: dict[str, JSON] | None = None,
357357
# runtime
358-
exists_ok: bool = False,
358+
overwrite: bool = False,
359359
data: npt.ArrayLike | None = None,
360360
) -> AsyncArray[ArrayV3Metadata] | AsyncArray[ArrayV2Metadata]: ...
361361

@@ -387,7 +387,7 @@ async def create(
387387
filters: list[dict[str, JSON]] | None = None,
388388
compressor: dict[str, JSON] | None = None,
389389
# runtime
390-
exists_ok: bool = False,
390+
overwrite: bool = False,
391391
data: npt.ArrayLike | None = None,
392392
) -> AsyncArray[ArrayV2Metadata] | AsyncArray[ArrayV3Metadata]:
393393
"""
@@ -429,7 +429,7 @@ async def create(
429429
compressor : dict[str, JSON], optional
430430
The compressor used to compress the data (default is None).
431431
V2 only. V3 arrays should not have 'compressor' parameter.
432-
exists_ok : bool, optional
432+
overwrite : bool, optional
433433
Whether to raise an error if the store already exists (default is False).
434434
data : npt.ArrayLike, optional
435435
The data to be inserted into the array (default is None).
@@ -489,7 +489,7 @@ async def create(
489489
codecs=codecs,
490490
dimension_names=dimension_names,
491491
attributes=attributes,
492-
exists_ok=exists_ok,
492+
overwrite=overwrite,
493493
order=order,
494494
)
495495
elif zarr_format == 2:
@@ -522,7 +522,7 @@ async def create(
522522
filters=filters,
523523
compressor=compressor,
524524
attributes=attributes,
525-
exists_ok=exists_ok,
525+
overwrite=overwrite,
526526
)
527527
else:
528528
raise ValueError(f"Insupported zarr_format. Got: {zarr_format}")
@@ -552,9 +552,9 @@ async def _create_v3(
552552
codecs: Iterable[Codec | dict[str, JSON]] | None = None,
553553
dimension_names: Iterable[str] | None = None,
554554
attributes: dict[str, JSON] | None = None,
555-
exists_ok: bool = False,
555+
overwrite: bool = False,
556556
) -> AsyncArray[ArrayV3Metadata]:
557-
if exists_ok:
557+
if overwrite:
558558
if store_path.store.supports_deletes:
559559
await store_path.delete_dir()
560560
else:
@@ -604,14 +604,14 @@ async def _create_v2(
604604
dtype: npt.DTypeLike,
605605
chunks: ChunkCoords,
606606
dimension_separator: Literal[".", "/"] | None = None,
607-
fill_value: None | float = None,
607+
fill_value: float | None = None,
608608
order: MemoryOrder | None = None,
609609
filters: list[dict[str, JSON]] | None = None,
610610
compressor: dict[str, JSON] | None = None,
611611
attributes: dict[str, JSON] | None = None,
612-
exists_ok: bool = False,
612+
overwrite: bool = False,
613613
) -> AsyncArray[ArrayV2Metadata]:
614-
if exists_ok:
614+
if overwrite:
615615
if store_path.store.supports_deletes:
616616
await store_path.delete_dir()
617617
else:
@@ -1463,7 +1463,7 @@ def create(
14631463
filters: list[dict[str, JSON]] | None = None,
14641464
compressor: dict[str, JSON] | None = None,
14651465
# runtime
1466-
exists_ok: bool = False,
1466+
overwrite: bool = False,
14671467
) -> Array:
14681468
"""Creates a new Array instance from an initialized store.
14691469
@@ -1493,7 +1493,7 @@ def create(
14931493
The filters used to compress the data (default is None).
14941494
compressor : dict[str, JSON], optional
14951495
The compressor used to compress the data (default is None).
1496-
exists_ok : bool, optional
1496+
overwrite : bool, optional
14971497
Whether to raise an error if the store already exists (default is False).
14981498
14991499
Returns
@@ -1518,7 +1518,7 @@ def create(
15181518
order=order,
15191519
filters=filters,
15201520
compressor=compressor,
1521-
exists_ok=exists_ok,
1521+
overwrite=overwrite,
15221522
),
15231523
)
15241524
return cls(async_array)

src/zarr/core/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
ChunkCoordsLike = Iterable[int]
3737
ZarrFormat = Literal[2, 3]
3838
NodeType = Literal["array", "group"]
39-
JSON = None | str | int | float | Mapping[str, "JSON"] | tuple["JSON", ...]
39+
JSON = str | int | float | Mapping[str, "JSON"] | tuple["JSON", ...] | None
4040
MemoryOrder = Literal["C", "F"]
4141
AccessModeLiteral = Literal["r", "r+", "a", "w", "w-"]
4242

0 commit comments

Comments
 (0)