Skip to content

Commit dd3dd96

Browse files
authored
Deprecate the experimental v3 implementation (#1802)
* deprecate(exp-v3): Add a future warning about the pending removal of the experimental v3 implementation * ignore warning * add test
1 parent b98f694 commit dd3dd96

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ filterwarnings = [
137137
"error:::zarr.*",
138138
"ignore:PY_SSIZE_T_CLEAN will be required.*:DeprecationWarning",
139139
"ignore:The loop argument is deprecated since Python 3.8.*:DeprecationWarning",
140+
"ignore:The experimental Zarr V3 implementation in this version .*:FutureWarning",
140141
]
141142

142143

zarr/_storage/store.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import abc
22
import os
3+
import warnings
34
from collections import defaultdict
45
from collections.abc import MutableMapping
56
from copy import copy
@@ -23,9 +24,21 @@
2324
DEFAULT_ZARR_VERSION: ZARR_VERSION = 2
2425

2526
v3_api_available = os.environ.get("ZARR_V3_EXPERIMENTAL_API", "0").lower() not in ["0", "false"]
27+
_has_warned_about_v3 = False # to avoid printing the warning multiple times
2628

2729

2830
def assert_zarr_v3_api_available():
31+
# we issue a warning about the experimental v3 implementation when it is first used
32+
global _has_warned_about_v3
33+
if v3_api_available and not _has_warned_about_v3:
34+
warnings.warn(
35+
"The experimental Zarr V3 implementation in this version of Zarr-Python is not "
36+
"in alignment with the final V3 specification. This version will be removed in "
37+
"Zarr-Python 3 in favor of a spec compliant version.",
38+
FutureWarning,
39+
stacklevel=1,
40+
)
41+
_has_warned_about_v3 = True
2942
if not v3_api_available:
3043
raise NotImplementedError(
3144
"# V3 reading and writing is experimental! To enable support, set:\n"

zarr/tests/test_storage_v3.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,18 @@
44
import inspect
55
import os
66
import tempfile
7+
import warnings
78

89
import numpy as np
910
import pytest
1011

1112
import zarr
12-
from zarr._storage.store import _get_hierarchy_metadata, v3_api_available, StorageTransformer
13+
from zarr._storage.store import (
14+
_get_hierarchy_metadata,
15+
assert_zarr_v3_api_available,
16+
v3_api_available,
17+
StorageTransformer,
18+
)
1319
from zarr._storage.v3_storage_transformers import ShardingStorageTransformer, v3_sharding_available
1420
from zarr.core import Array
1521
from zarr.meta import _default_entry_point_metadata_v3
@@ -668,6 +674,18 @@ def test_top_level_imports():
668674
assert not hasattr(zarr, store_name) # pragma: no cover
669675

670676

677+
def test_assert_zarr_v3_api_available_warns_once():
678+
import zarr._storage.store
679+
680+
zarr._storage.store._has_warned_about_v3 = False
681+
warnings.resetwarnings()
682+
with pytest.warns() as record:
683+
assert_zarr_v3_api_available()
684+
assert_zarr_v3_api_available()
685+
assert len(record) == 1
686+
assert "The experimental Zarr V3 implementation" in str(record[0].message)
687+
688+
671689
def _get_public_and_dunder_methods(some_class):
672690
return set(
673691
name

0 commit comments

Comments
 (0)