Skip to content

Commit 2f29144

Browse files
authored
deprecate(stores): add deprecation warnings to stores that we plan to remove in v3 (#1801)
* deprecate(stores): add deprecation warnings to DBMStore, LMDBStore, SQLiteStore, MongoDBStore, RedisStore, and ABSStore * filter warnings in pytest config * more deprecation warnings in docstrings * add release note
1 parent 9331430 commit 2f29144

File tree

5 files changed

+95
-1
lines changed

5 files changed

+95
-1
lines changed

docs/release.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ Deprecations
4343
Also updated docs to warn about using the experimental v3 version.
4444
By :user:`Joe Hamman <jhamman>` :issue:`1802` and :issue: `1807`.
4545

46+
Deprecations
47+
~~~~~~~~~~~~
48+
* Deprecate the following stores: :class:`zarr.storage.DBMStore`, :class:`zarr.storage.LMDBStore`,
49+
:class:`zarr.storage.SQLiteStore`, :class:`zarr.storage.MongoDBStore`, :class:`zarr.storage.RedisStore`,
50+
and :class:`zarr.storage.ABSStore`. These stores are slated to be removed from Zarr-Python in version 3.0.
51+
By :user:`Joe Hamman <jhamman>` :issue:`1801`.
52+
4653
.. _release_2.17.2:
4754

4855
2.17.2

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 .* is deprecated and will be removed in a Zarr-Python version 3*:FutureWarning",
140141
"ignore:The experimental Zarr V3 implementation in this version .*:FutureWarning",
141142
]
142143

zarr/_storage/absstore.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,14 @@
55

66
from numcodecs.compat import ensure_bytes
77
from zarr.util import normalize_storage_path
8-
from zarr._storage.store import _get_metadata_suffix, data_root, meta_root, Store, StoreV3
8+
from zarr._storage.store import (
9+
_get_metadata_suffix,
10+
data_root,
11+
meta_root,
12+
Store,
13+
StoreV3,
14+
V3_DEPRECATION_MESSAGE,
15+
)
916
from zarr.types import DIMENSION_SEPARATOR
1017

1118
__doctest_requires__ = {
@@ -73,6 +80,12 @@ def __init__(
7380
dimension_separator: Optional[DIMENSION_SEPARATOR] = None,
7481
client=None,
7582
):
83+
warnings.warn(
84+
V3_DEPRECATION_MESSAGE.format(store=self.__class__.__name__),
85+
FutureWarning,
86+
stacklevel=3,
87+
)
88+
7689
self._dimension_separator = dimension_separator
7790
self.prefix = normalize_storage_path(prefix)
7891
if client is None:

zarr/_storage/store.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@
2626
v3_api_available = os.environ.get("ZARR_V3_EXPERIMENTAL_API", "0").lower() not in ["0", "false"]
2727
_has_warned_about_v3 = False # to avoid printing the warning multiple times
2828

29+
V3_DEPRECATION_MESSAGE = (
30+
"The {store} is deprecated and will be removed in a Zarr-Python version 3, see "
31+
"https://github.com/zarr-developers/zarr-python/issues/1274 for more information."
32+
)
33+
2934

3035
def assert_zarr_v3_api_available():
3136
# we issue a warning about the experimental v3 implementation when it is first used

zarr/storage.py

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
DEFAULT_ZARR_VERSION,
8989
BaseStore,
9090
Store,
91+
V3_DEPRECATION_MESSAGE,
9192
)
9293

9394
__doctest_requires__ = {
@@ -1604,6 +1605,12 @@ class NestedDirectoryStore(DirectoryStore):
16041605
special handling for chunk keys so that chunk files for multidimensional
16051606
arrays are stored in a nested directory tree.
16061607
1608+
.. deprecated:: 2.18.0
1609+
NestedDirectoryStore will be removed in Zarr-Python 3.0 where controlling
1610+
the chunk key encoding will be supported as part of the array metadata. See
1611+
`GH1274 <https://github.com/zarr-developers/zarr-python/issues/1274>`_
1612+
for more information.
1613+
16071614
Parameters
16081615
----------
16091616
path : string
@@ -1675,6 +1682,13 @@ class NestedDirectoryStore(DirectoryStore):
16751682
def __init__(
16761683
self, path, normalize_keys=False, dimension_separator: Optional[DIMENSION_SEPARATOR] = "/"
16771684
):
1685+
1686+
warnings.warn(
1687+
V3_DEPRECATION_MESSAGE.format(store=self.__class__.__name__),
1688+
FutureWarning,
1689+
stacklevel=2,
1690+
)
1691+
16781692
super().__init__(path, normalize_keys=normalize_keys)
16791693
if dimension_separator is None:
16801694
dimension_separator = "/"
@@ -1995,6 +2009,11 @@ def migrate_1to2(store):
19952009
class DBMStore(Store):
19962010
"""Storage class using a DBM-style database.
19972011
2012+
.. deprecated:: 2.18.0
2013+
DBMStore will be removed in Zarr-Python 3.0. See
2014+
`GH1274 <https://github.com/zarr-developers/zarr-python/issues/1274>`_
2015+
for more information.
2016+
19982017
Parameters
19992018
----------
20002019
path : string
@@ -2083,6 +2102,12 @@ def __init__(
20832102
dimension_separator: Optional[DIMENSION_SEPARATOR] = None,
20842103
**open_kwargs,
20852104
):
2105+
warnings.warn(
2106+
V3_DEPRECATION_MESSAGE.format(store=self.__class__.__name__),
2107+
FutureWarning,
2108+
stacklevel=2,
2109+
)
2110+
20862111
if open is None:
20872112
import dbm
20882113

@@ -2200,6 +2225,10 @@ class LMDBStore(Store):
22002225
"""Storage class using LMDB. Requires the `lmdb <https://lmdb.readthedocs.io/>`_
22012226
package to be installed.
22022227
2228+
.. deprecated:: 2.18.0
2229+
LMDBStore will be removed in Zarr-Python 3.0. See
2230+
`GH1274 <https://github.com/zarr-developers/zarr-python/issues/1274>`_
2231+
for more information.
22032232
22042233
Parameters
22052234
----------
@@ -2261,6 +2290,12 @@ def __init__(
22612290
):
22622291
import lmdb
22632292

2293+
warnings.warn(
2294+
V3_DEPRECATION_MESSAGE.format(store=self.__class__.__name__),
2295+
FutureWarning,
2296+
stacklevel=2,
2297+
)
2298+
22642299
# set default memory map size to something larger than the lmdb default, which is
22652300
# very likely to be too small for any moderate array (logic copied from zict)
22662301
map_size = 2**40 if sys.maxsize >= 2**32 else 2**28
@@ -2580,6 +2615,11 @@ def __delitem__(self, key):
25802615
class SQLiteStore(Store):
25812616
"""Storage class using SQLite.
25822617
2618+
.. deprecated:: 2.18.0
2619+
SQLiteStore will be removed in Zarr-Python 3.0. See
2620+
`GH1274 <https://github.com/zarr-developers/zarr-python/issues/1274>`_
2621+
for more information.
2622+
25832623
Parameters
25842624
----------
25852625
path : string
@@ -2612,6 +2652,12 @@ class SQLiteStore(Store):
26122652
def __init__(self, path, dimension_separator: Optional[DIMENSION_SEPARATOR] = None, **kwargs):
26132653
import sqlite3
26142654

2655+
warnings.warn(
2656+
V3_DEPRECATION_MESSAGE.format(store=self.__class__.__name__),
2657+
FutureWarning,
2658+
stacklevel=2,
2659+
)
2660+
26152661
self._dimension_separator = dimension_separator
26162662

26172663
# normalize path
@@ -2778,6 +2824,11 @@ class MongoDBStore(Store):
27782824
27792825
.. note:: This is an experimental feature.
27802826
2827+
.. deprecated:: 2.18.0
2828+
MongoDBStore will be removed in Zarr-Python 3.0. See
2829+
`GH1274 <https://github.com/zarr-developers/zarr-python/issues/1274>`_
2830+
for more information.
2831+
27812832
Requires the `pymongo <https://pymongo.readthedocs.io/en/stable/>`_
27822833
package to be installed.
27832834
@@ -2810,6 +2861,12 @@ def __init__(
28102861
):
28112862
import pymongo
28122863

2864+
warnings.warn(
2865+
V3_DEPRECATION_MESSAGE.format(store=self.__class__.__name__),
2866+
FutureWarning,
2867+
stacklevel=2,
2868+
)
2869+
28132870
self._database = database
28142871
self._collection = collection
28152872
self._dimension_separator = dimension_separator
@@ -2866,6 +2923,11 @@ class RedisStore(Store):
28662923
28672924
.. note:: This is an experimental feature.
28682925
2926+
.. deprecated:: 2.18.0
2927+
RedisStore will be removed in Zarr-Python 3.0. See
2928+
`GH1274 <https://github.com/zarr-developers/zarr-python/issues/1274>`_
2929+
for more information.
2930+
28692931
Requires the `redis <https://redis-py.readthedocs.io/>`_
28702932
package to be installed.
28712933
@@ -2885,6 +2947,12 @@ def __init__(
28852947
):
28862948
import redis
28872949

2950+
warnings.warn(
2951+
V3_DEPRECATION_MESSAGE.format(store=self.__class__.__name__),
2952+
FutureWarning,
2953+
stacklevel=2,
2954+
)
2955+
28882956
self._prefix = prefix
28892957
self._kwargs = kwargs
28902958
self._dimension_separator = dimension_separator

0 commit comments

Comments
 (0)