Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/3883.misc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Do not warn with `shards="auto"` when `zarr.config.array.target_shard_size_bytes` is set.
12 changes: 7 additions & 5 deletions src/zarr/core/chunk_grids.py
Original file line number Diff line number Diff line change
Expand Up @@ -756,13 +756,15 @@ def _auto_partition(
_chunks_out = chunk_shape

if shard_shape == "auto":
warnings.warn(
"Automatic shard shape inference is experimental and may change without notice.",
ZarrUserWarning,
stacklevel=2,
)
_shards_out = ()
target_shard_size_bytes = zarr.config.get("array.target_shard_size_bytes", None)
if target_shard_size_bytes is None:
warnings.warn(
"Automatic shard shape inference is experimental and may change without notice."
"To set a target uncompressed shard size, use zarr.config.array.target_shard_size_bytes.",
ZarrUserWarning,
stacklevel=2,
)
num_chunks_per_shard_axis = (
_guess_num_chunks_per_axis_shard(
chunk_shape=_chunks_out,
Expand Down
29 changes: 15 additions & 14 deletions tests/test_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import pickle
import re
import sys
from contextlib import nullcontext
from itertools import accumulate, starmap
from typing import TYPE_CHECKING, Any, Literal
from unittest import mock
Expand Down Expand Up @@ -1073,9 +1074,13 @@ def test_auto_partition_auto_shards(
where there are 8 or more chunks.
"""
dtype = np.dtype("uint8")
with pytest.warns(
ZarrUserWarning,
match="Automatic shard shape inference is experimental and may change without notice.",
with (
pytest.warns(
ZarrUserWarning,
match="Automatic shard shape inference is experimental and may change without notice.",
)
if target_shard_size_bytes is None
else nullcontext()
):
with zarr.config.set({"array.target_shard_size_bytes": target_shard_size_bytes}):
auto_shards, _ = _auto_partition(
Expand All @@ -1091,17 +1096,13 @@ def test_auto_partition_auto_shards_with_auto_chunks_should_be_close_to_1MiB() -
"""
Test that automatically picking a shard size and a chunk size gives roughly 1MiB chunks.
"""
with pytest.warns(
ZarrUserWarning,
match="Automatic shard shape inference is experimental and may change without notice.",
):
with zarr.config.set({"array.target_shard_size_bytes": 10_000_000}):
_, chunk_shape = _auto_partition(
array_shape=(10_000_000,),
chunk_shape="auto",
shard_shape="auto",
item_size=1,
)
with zarr.config.set({"array.target_shard_size_bytes": 10_000_000}):
_, chunk_shape = _auto_partition(
array_shape=(10_000_000,),
chunk_shape="auto",
shard_shape="auto",
item_size=1,
)
assert chunk_shape == (625000,)


Expand Down
Loading