Skip to content

Commit 6791076

Browse files
committed
COMP: Ignore Zarr Python 3 consolidated metadata warning
1 parent 853fdd2 commit 6791076

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

ngff_zarr/to_ngff_zarr.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from pathlib import Path, PurePosixPath
55
from typing import Optional, Union, Tuple, Dict
66
from packaging import version
7+
import warnings
78

89
if sys.version_info < (3, 10):
910
import importlib_metadata
@@ -197,7 +198,7 @@ def to_ngff_zarr(
197198
:param progress: Optional progress logger
198199
:type progress: RichDaskProgress
199200
200-
:param chunks_per_shard: Number of chunks along each axis in a shard. If None, no sharding. Requires zarr version >= 0.5.
201+
:param chunks_per_shard: Number of chunks along each axis in a shard. If None, no sharding. Requires OME-Zarr version >= 0.5.
201202
:type chunks_per_shard: int, tuple, or dict, optional
202203
203204
:param **kwargs: Passed to the zarr.creation.create() function, e.g., compression options.
@@ -609,4 +610,10 @@ def to_ngff_zarr(
609610
callback()
610611
image.computed_callbacks = []
611612

612-
zarr.consolidate_metadata(store, **format_kwargs)
613+
if zarr_version_major >= 3:
614+
with warnings.catch_warnings():
615+
# Ignore consolidated metadata warning
616+
warnings.filterwarnings("ignore", category=UserWarning)
617+
zarr.consolidate_metadata(store, **format_kwargs)
618+
else:
619+
zarr.consolidate_metadata(store, **format_kwargs)

0 commit comments

Comments
 (0)