File tree Expand file tree Collapse file tree 3 files changed +33
-1
lines changed Expand file tree Collapse file tree 3 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -137,6 +137,7 @@ filterwarnings = [
137
137
" error:::zarr.*" ,
138
138
" ignore:PY_SSIZE_T_CLEAN will be required.*:DeprecationWarning" ,
139
139
" ignore:The loop argument is deprecated since Python 3.8.*:DeprecationWarning" ,
140
+ " ignore:The experimental Zarr V3 implementation in this version .*:FutureWarning" ,
140
141
]
141
142
142
143
Original file line number Diff line number Diff line change 1
1
import abc
2
2
import os
3
+ import warnings
3
4
from collections import defaultdict
4
5
from collections .abc import MutableMapping
5
6
from copy import copy
23
24
DEFAULT_ZARR_VERSION : ZARR_VERSION = 2
24
25
25
26
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
26
28
27
29
28
30
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
29
42
if not v3_api_available :
30
43
raise NotImplementedError (
31
44
"# V3 reading and writing is experimental! To enable support, set:\n "
Original file line number Diff line number Diff line change 4
4
import inspect
5
5
import os
6
6
import tempfile
7
+ import warnings
7
8
8
9
import numpy as np
9
10
import pytest
10
11
11
12
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
+ )
13
19
from zarr ._storage .v3_storage_transformers import ShardingStorageTransformer , v3_sharding_available
14
20
from zarr .core import Array
15
21
from zarr .meta import _default_entry_point_metadata_v3
@@ -668,6 +674,18 @@ def test_top_level_imports():
668
674
assert not hasattr (zarr , store_name ) # pragma: no cover
669
675
670
676
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
+
671
689
def _get_public_and_dunder_methods (some_class ):
672
690
return set (
673
691
name
You can’t perform that action at this time.
0 commit comments