From b655d24bfb4d0cc1bedfed769416a30ccfd431d4 Mon Sep 17 00:00:00 2001 From: Joseph Hamman Date: Thu, 18 Apr 2024 20:48:03 -0700 Subject: [PATCH 1/4] deprecate(stores): add deprecation warnings to DBMStore, LMDBStore, SQLiteStore, MongoDBStore, RedisStore, and ABSStore --- zarr/_storage/absstore.py | 15 ++++++++++++++- zarr/_storage/store.py | 5 +++++ zarr/storage.py | 31 +++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 1 deletion(-) diff --git a/zarr/_storage/absstore.py b/zarr/_storage/absstore.py index 217b2a29e0..5d2606f2f2 100644 --- a/zarr/_storage/absstore.py +++ b/zarr/_storage/absstore.py @@ -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__ = { @@ -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: diff --git a/zarr/_storage/store.py b/zarr/_storage/store.py index 0a08080548..bc4a3ca496 100644 --- a/zarr/_storage/store.py +++ b/zarr/_storage/store.py @@ -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: diff --git a/zarr/storage.py b/zarr/storage.py index 10f55f0ba3..7f03462403 100644 --- a/zarr/storage.py +++ b/zarr/storage.py @@ -88,6 +88,7 @@ DEFAULT_ZARR_VERSION, BaseStore, Store, + V3_DEPRECATION_MESSAGE, ) __doctest_requires__ = { @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 From 9e78847b11f307185e22da6725649b318273f443 Mon Sep 17 00:00:00 2001 From: Joseph Hamman Date: Fri, 19 Apr 2024 09:50:49 -0700 Subject: [PATCH 2/4] filter warnings in pytest config --- pyproject.toml | 1 + zarr/_storage/store.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 0be79f990e..d6afe01eaa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -137,6 +137,7 @@ filterwarnings = [ "error:::zarr.*", "ignore:PY_SSIZE_T_CLEAN will be required.*:DeprecationWarning", "ignore:The loop argument is deprecated since Python 3.8.*:DeprecationWarning", + "ignore:The .* is deprecated and will be removed in a Zarr-Python version 3*:FutureWarning", ] diff --git a/zarr/_storage/store.py b/zarr/_storage/store.py index bc4a3ca496..f1619af3b1 100644 --- a/zarr/_storage/store.py +++ b/zarr/_storage/store.py @@ -25,7 +25,7 @@ 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" + "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." ) From 963bdfa6f9304f8e0321045da53c3a337f6fc4bf Mon Sep 17 00:00:00 2001 From: Joseph Hamman Date: Wed, 24 Apr 2024 12:40:35 -0700 Subject: [PATCH 3/4] more deprecation warnings in docstrings --- zarr/storage.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/zarr/storage.py b/zarr/storage.py index 7f03462403..772fa7646a 100644 --- a/zarr/storage.py +++ b/zarr/storage.py @@ -1605,6 +1605,12 @@ class NestedDirectoryStore(DirectoryStore): special handling for chunk keys so that chunk files for multidimensional arrays are stored in a nested directory tree. + .. deprecated:: 2.18.0 + NestedDirectoryStore will be removed in Zarr-Python 3.0 where controlling + the chunk key encoding will be supported as part of the array metadata. See + `GH1274 `_ + for more information. + Parameters ---------- path : string @@ -1676,6 +1682,13 @@ class NestedDirectoryStore(DirectoryStore): def __init__( self, path, normalize_keys=False, dimension_separator: Optional[DIMENSION_SEPARATOR] = "/" ): + + warnings.warn( + V3_DEPRECATION_MESSAGE.format(store=self.__class__.__name__), + FutureWarning, + stacklevel=2, + ) + super().__init__(path, normalize_keys=normalize_keys) if dimension_separator is None: dimension_separator = "/" @@ -1996,6 +2009,11 @@ def migrate_1to2(store): class DBMStore(Store): """Storage class using a DBM-style database. + .. deprecated:: 2.18.0 + DBMStore will be removed in Zarr-Python 3.0. See + `GH1274 `_ + for more information. + Parameters ---------- path : string @@ -2207,6 +2225,10 @@ class LMDBStore(Store): """Storage class using LMDB. Requires the `lmdb `_ package to be installed. + .. deprecated:: 2.18.0 + LMDBStore will be removed in Zarr-Python 3.0. See + `GH1274 `_ + for more information. Parameters ---------- @@ -2593,6 +2615,11 @@ def __delitem__(self, key): class SQLiteStore(Store): """Storage class using SQLite. + .. deprecated:: 2.18.0 + SQLiteStore will be removed in Zarr-Python 3.0. See + `GH1274 `_ + for more information. + Parameters ---------- path : string @@ -2797,6 +2824,11 @@ class MongoDBStore(Store): .. note:: This is an experimental feature. + .. deprecated:: 2.18.0 + MongoDBStore will be removed in Zarr-Python 3.0. See + `GH1274 `_ + for more information. + Requires the `pymongo `_ package to be installed. @@ -2891,6 +2923,11 @@ class RedisStore(Store): .. note:: This is an experimental feature. + .. deprecated:: 2.18.0 + RedisStore will be removed in Zarr-Python 3.0. See + `GH1274 `_ + for more information. + Requires the `redis `_ package to be installed. From 0516cc139784d21d6071c1bca0bbc56683a9bec3 Mon Sep 17 00:00:00 2001 From: Joseph Hamman Date: Wed, 24 Apr 2024 12:44:03 -0700 Subject: [PATCH 4/4] add release note --- docs/release.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/release.rst b/docs/release.rst index 07c2a47e7c..efbc00d6ad 100644 --- a/docs/release.rst +++ b/docs/release.rst @@ -32,6 +32,13 @@ Maintenance ~~~~~~~~~~~ +Deprecations +~~~~~~~~~~~~ +* Deprecate the following stores: :class:`zarr.storage.DBMStore`, :class:`zarr.storage.LMDBStore`, + :class:`zarr.storage.SQLiteStore`, :class:`zarr.storage.MongoDBStore`, :class:`zarr.storage.RedisStore`, + and :class:`zarr.storage.ABSStore`. These stores are slated to be removed from Zarr-Python in version 3.0. + By :user:`Joe Hamman ` :issue:`1801`. + .. _release_2.17.2: 2.17.2