Skip to content

Commit 9f14cee

Browse files
committed
chore: no warning if target shard size is set with auto
1 parent c966cfa commit 9f14cee

2 files changed

Lines changed: 21 additions & 27 deletions

File tree

src/zarr/core/chunk_grids.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -756,13 +756,15 @@ def _auto_partition(
756756
_chunks_out = chunk_shape
757757

758758
if shard_shape == "auto":
759-
warnings.warn(
760-
"Automatic shard shape inference is experimental and may change without notice.",
761-
ZarrUserWarning,
762-
stacklevel=2,
763-
)
764759
_shards_out = ()
765760
target_shard_size_bytes = zarr.config.get("array.target_shard_size_bytes", None)
761+
if target_shard_size_bytes is None:
762+
warnings.warn(
763+
"Automatic shard shape inference is experimental and may change without notice."
764+
"To set a target uncompressed shard size, use zarr.config.array.target_shard_size_bytes.",
765+
ZarrUserWarning,
766+
stacklevel=2,
767+
)
766768
num_chunks_per_shard_axis = (
767769
_guess_num_chunks_per_axis_shard(
768770
chunk_shape=_chunks_out,

tests/test_array.py

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,35 +1073,27 @@ def test_auto_partition_auto_shards(
10731073
where there are 8 or more chunks.
10741074
"""
10751075
dtype = np.dtype("uint8")
1076-
with pytest.warns(
1077-
ZarrUserWarning,
1078-
match="Automatic shard shape inference is experimental and may change without notice.",
1079-
):
1080-
with zarr.config.set({"array.target_shard_size_bytes": target_shard_size_bytes}):
1081-
auto_shards, _ = _auto_partition(
1082-
array_shape=array_shape,
1083-
chunk_shape=chunk_shape,
1084-
shard_shape="auto",
1085-
item_size=dtype.itemsize,
1086-
)
1076+
with zarr.config.set({"array.target_shard_size_bytes": target_shard_size_bytes}):
1077+
auto_shards, _ = _auto_partition(
1078+
array_shape=array_shape,
1079+
chunk_shape=chunk_shape,
1080+
shard_shape="auto",
1081+
item_size=dtype.itemsize,
1082+
)
10871083
assert auto_shards == expected_shards
10881084

10891085

10901086
def test_auto_partition_auto_shards_with_auto_chunks_should_be_close_to_1MiB() -> None:
10911087
"""
10921088
Test that automatically picking a shard size and a chunk size gives roughly 1MiB chunks.
10931089
"""
1094-
with pytest.warns(
1095-
ZarrUserWarning,
1096-
match="Automatic shard shape inference is experimental and may change without notice.",
1097-
):
1098-
with zarr.config.set({"array.target_shard_size_bytes": 10_000_000}):
1099-
_, chunk_shape = _auto_partition(
1100-
array_shape=(10_000_000,),
1101-
chunk_shape="auto",
1102-
shard_shape="auto",
1103-
item_size=1,
1104-
)
1090+
with zarr.config.set({"array.target_shard_size_bytes": 10_000_000}):
1091+
_, chunk_shape = _auto_partition(
1092+
array_shape=(10_000_000,),
1093+
chunk_shape="auto",
1094+
shard_shape="auto",
1095+
item_size=1,
1096+
)
11051097
assert chunk_shape == (625000,)
11061098

11071099

0 commit comments

Comments
 (0)