Skip to content

Commit

Permalink
deprecate(stores): add deprecation warnings to DBMStore, LMDBStore, S…
Browse files Browse the repository at this point in the history
…QLiteStore, MongoDBStore, RedisStore, and ABSStore
  • Loading branch information
jhamman committed Apr 19, 2024
1 parent 6105ef2 commit b655d24
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
15 changes: 14 additions & 1 deletion zarr/_storage/absstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@

from numcodecs.compat import ensure_bytes
from zarr.util import normalize_storage_path
from zarr._storage.store import _get_metadata_suffix, data_root, meta_root, Store, StoreV3
from zarr._storage.store import (
_get_metadata_suffix,
data_root,
meta_root,
Store,
StoreV3,
V3_DEPRECATION_MESSAGE,
)
from zarr.types import DIMENSION_SEPARATOR

__doctest_requires__ = {
Expand Down Expand Up @@ -73,6 +80,12 @@ def __init__(
dimension_separator: Optional[DIMENSION_SEPARATOR] = None,
client=None,
):
warnings.warn(
V3_DEPRECATION_MESSAGE.format(store=self.__class__.__name__),
FutureWarning,
stacklevel=3,
)

self._dimension_separator = dimension_separator
self.prefix = normalize_storage_path(prefix)
if client is None:
Expand Down
5 changes: 5 additions & 0 deletions zarr/_storage/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@

v3_api_available = os.environ.get("ZARR_V3_EXPERIMENTAL_API", "0").lower() not in ["0", "false"]

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


def assert_zarr_v3_api_available():
if not v3_api_available:
Expand Down
31 changes: 31 additions & 0 deletions zarr/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
DEFAULT_ZARR_VERSION,
BaseStore,
Store,
V3_DEPRECATION_MESSAGE,
)

__doctest_requires__ = {
Expand Down Expand Up @@ -2083,6 +2084,12 @@ def __init__(
dimension_separator: Optional[DIMENSION_SEPARATOR] = None,
**open_kwargs,
):
warnings.warn(
V3_DEPRECATION_MESSAGE.format(store=self.__class__.__name__),
FutureWarning,
stacklevel=2,
)

if open is None:
import dbm

Expand Down Expand Up @@ -2261,6 +2268,12 @@ def __init__(
):
import lmdb

warnings.warn(
V3_DEPRECATION_MESSAGE.format(store=self.__class__.__name__),
FutureWarning,
stacklevel=2,
)

# set default memory map size to something larger than the lmdb default, which is
# very likely to be too small for any moderate array (logic copied from zict)
map_size = 2**40 if sys.maxsize >= 2**32 else 2**28
Expand Down Expand Up @@ -2612,6 +2625,12 @@ class SQLiteStore(Store):
def __init__(self, path, dimension_separator: Optional[DIMENSION_SEPARATOR] = None, **kwargs):
import sqlite3

warnings.warn(
V3_DEPRECATION_MESSAGE.format(store=self.__class__.__name__),
FutureWarning,
stacklevel=2,
)

self._dimension_separator = dimension_separator

# normalize path
Expand Down Expand Up @@ -2810,6 +2829,12 @@ def __init__(
):
import pymongo

warnings.warn(
V3_DEPRECATION_MESSAGE.format(store=self.__class__.__name__),
FutureWarning,
stacklevel=2,
)

self._database = database
self._collection = collection
self._dimension_separator = dimension_separator
Expand Down Expand Up @@ -2885,6 +2910,12 @@ def __init__(
):
import redis

warnings.warn(
V3_DEPRECATION_MESSAGE.format(store=self.__class__.__name__),
FutureWarning,
stacklevel=2,
)

self._prefix = prefix
self._kwargs = kwargs
self._dimension_separator = dimension_separator
Expand Down

0 comments on commit b655d24

Please sign in to comment.