From 4b205013528455579c4d9bb79408ec4436d712f8 Mon Sep 17 00:00:00 2001 From: Davis Bennett Date: Thu, 4 Apr 2024 13:14:41 +0200 Subject: [PATCH] chore: add deprecation warnings to v3 classes / functions --- src/zarr/_storage/absstore.py | 4 ++ src/zarr/_storage/store.py | 20 +++++++++ src/zarr/_storage/v3.py | 43 ++++++++++++++++++++ src/zarr/_storage/v3_storage_transformers.py | 4 ++ src/zarr/meta.py | 4 ++ 5 files changed, 75 insertions(+) diff --git a/src/zarr/_storage/absstore.py b/src/zarr/_storage/absstore.py index f62529f09..f8382714c 100644 --- a/src/zarr/_storage/absstore.py +++ b/src/zarr/_storage/absstore.py @@ -1,5 +1,6 @@ """This module contains storage classes related to Azure Blob Storage (ABS)""" +from typing_extensions import deprecated import warnings from numcodecs.compat import ensure_bytes from zarr.util import normalize_storage_path @@ -224,6 +225,9 @@ def clear(self): self.rmdir() +@deprecated( + "This implementation of Zarr V3 is out of date and will be supplanted in zarr-python 3.0" +) class ABSStoreV3(ABSStore, StoreV3): def list(self): return list(self.keys()) diff --git a/src/zarr/_storage/store.py b/src/zarr/_storage/store.py index 8daedae48..cacb265bf 100644 --- a/src/zarr/_storage/store.py +++ b/src/zarr/_storage/store.py @@ -10,6 +10,8 @@ from zarr.util import normalize_storage_path from zarr.context import Context +from typing_extensions import deprecated + # v2 store keys array_meta_key = ".zarray" group_meta_key = ".zgroup" @@ -182,6 +184,9 @@ def rmdir(self, path: str = "") -> None: _rmdir_from_keys(self, path) +@deprecated( + "This implementation of Zarr V3 is out of date and will be supplanted in zarr-python 3.0" +) class StoreV3(BaseStore): _store_version = 3 _metadata_class = Metadata3 @@ -405,6 +410,9 @@ def _ensure_store(store): ) +@deprecated( + "This implementation of Zarr V3 is out of date and will be supplanted in zarr-python 3.0" +) class StorageTransformer(MutableMapping, abc.ABC): """Base class for storage transformers. The methods simply pass on the data as-is and should be overwritten by sub-classes.""" @@ -560,6 +568,9 @@ def _path_to_prefix(path: Optional[str]) -> str: return prefix +@deprecated( + "This implementation of Zarr V3 is out of date and will be supplanted in zarr-python 3.0" +) def _get_hierarchy_metadata(store: StoreV3) -> Mapping[str, Any]: version = getattr(store, "_store_version", 2) if version < 3: @@ -569,12 +580,18 @@ def _get_hierarchy_metadata(store: StoreV3) -> Mapping[str, Any]: return store._metadata_class.decode_hierarchy_metadata(store["zarr.json"]) +@deprecated( + "This implementation of Zarr V3 is out of date and will be supplanted in zarr-python 3.0" +) def _get_metadata_suffix(store: StoreV3) -> str: if "zarr.json" in store: return _get_hierarchy_metadata(store)["metadata_key_suffix"] return ".json" +@deprecated( + "This implementation of Zarr V3 is out of date and will be supplanted in zarr-python 3.0" +) def _rename_metadata_v3(store: StoreV3, src_path: str, dst_path: str) -> bool: """Rename source or group metadata file associated with src_path.""" any_renamed = False @@ -628,6 +645,9 @@ def _rmdir_from_keys(store: StoreLike, path: Optional[str] = None) -> None: del store[key] +@deprecated( + "This implementation of Zarr V3 is out of date and will be supplanted in zarr-python 3.0" +) def _rmdir_from_keys_v3(store: StoreV3, path: str = "") -> None: meta_dir = meta_root + path diff --git a/src/zarr/_storage/v3.py b/src/zarr/_storage/v3.py index 8ab54984b..1d909df79 100644 --- a/src/zarr/_storage/v3.py +++ b/src/zarr/_storage/v3.py @@ -4,6 +4,7 @@ from collections.abc import MutableMapping from threading import Lock from typing import Union, Dict, Any +from typing_extensions import deprecated from zarr.errors import ( MetadataError, @@ -71,6 +72,9 @@ StoreLike = Union[BaseStore, MutableMapping] +@deprecated( + "This implementation of Zarr V3 is out of date and will be supplanted in zarr-python 3.0" +) class RmdirV3: """Mixin class that can be used to ensure override of any existing v2 rmdir class.""" @@ -79,6 +83,9 @@ def rmdir(self, path: str = "") -> None: _rmdir_from_keys_v3(self, path) # type: ignore +@deprecated( + "This implementation of Zarr V3 is out of date and will be supplanted in zarr-python 3.0" +) class KVStoreV3(RmdirV3, KVStore, StoreV3): def list(self): return list(self._mutable_mapping.keys()) @@ -117,6 +124,9 @@ def _get_files_and_dirs_from_path(store, path): return files, dirs +@deprecated( + "This implementation of Zarr V3 is out of date and will be supplanted in zarr-python 3.0" +) class FSStoreV3(FSStore, StoreV3): # FSStoreV3 doesn't use this (FSStore uses it within _normalize_key) @@ -224,6 +234,9 @@ def get_partial_values(self, key_ranges): return results +@deprecated( + "This implementation of Zarr V3 is out of date and will be supplanted in zarr-python 3.0" +) class MemoryStoreV3(MemoryStore, StoreV3): def __init__(self, root=None, cls=dict, dimension_separator=None): if root is None: @@ -306,6 +319,9 @@ def rmdir(self, path: Path = None): MemoryStoreV3.__doc__ = MemoryStore.__doc__ +@deprecated( + "This implementation of Zarr V3 is out of date and will be supplanted in zarr-python 3.0" +) class DirectoryStoreV3(DirectoryStore, StoreV3): def list(self): return list(self.keys()) @@ -369,6 +385,9 @@ def rmdir(self, path=None): DirectoryStoreV3.__doc__ = DirectoryStore.__doc__ +@deprecated( + "This implementation of Zarr V3 is out of date and will be supplanted in zarr-python 3.0" +) class ZipStoreV3(ZipStore, StoreV3): def list(self): return list(self.keys()) @@ -407,6 +426,9 @@ def getsize(self, path=None): ZipStoreV3.__doc__ = ZipStore.__doc__ +@deprecated( + "This implementation of Zarr V3 is out of date and will be supplanted in zarr-python 3.0" +) class RedisStoreV3(RmdirV3, RedisStore, StoreV3): def list(self): return list(self.keys()) @@ -419,6 +441,9 @@ def __setitem__(self, key, value): RedisStoreV3.__doc__ = RedisStore.__doc__ +@deprecated( + "This implementation of Zarr V3 is out of date and will be supplanted in zarr-python 3.0" +) class MongoDBStoreV3(RmdirV3, MongoDBStore, StoreV3): def list(self): return list(self.keys()) @@ -431,6 +456,9 @@ def __setitem__(self, key, value): MongoDBStoreV3.__doc__ = MongoDBStore.__doc__ +@deprecated( + "This implementation of Zarr V3 is out of date and will be supplanted in zarr-python 3.0" +) class DBMStoreV3(RmdirV3, DBMStore, StoreV3): def list(self): return list(self.keys()) @@ -443,6 +471,9 @@ def __setitem__(self, key, value): DBMStoreV3.__doc__ = DBMStore.__doc__ +@deprecated( + "This implementation of Zarr V3 is out of date and will be supplanted in zarr-python 3.0" +) class LMDBStoreV3(RmdirV3, LMDBStore, StoreV3): def list(self): return list(self.keys()) @@ -455,6 +486,9 @@ def __setitem__(self, key, value): LMDBStoreV3.__doc__ = LMDBStore.__doc__ +@deprecated( + "This implementation of Zarr V3 is out of date and will be supplanted in zarr-python 3.0" +) class SQLiteStoreV3(SQLiteStore, StoreV3): def list(self): return list(self.keys()) @@ -503,6 +537,9 @@ def rmdir(self, path=None): SQLiteStoreV3.__doc__ = SQLiteStore.__doc__ +@deprecated( + "This implementation of Zarr V3 is out of date and will be supplanted in zarr-python 3.0" +) class LRUStoreCacheV3(RmdirV3, LRUStoreCache, StoreV3): def __init__(self, store, max_size: int): self._store = StoreV3._ensure_store(store) @@ -526,6 +563,9 @@ def __setitem__(self, key, value): LRUStoreCacheV3.__doc__ = LRUStoreCache.__doc__ +@deprecated( + "This implementation of Zarr V3 is out of date and will be supplanted in zarr-python 3.0" +) class ConsolidatedMetadataStoreV3(ConsolidatedMetadataStore, StoreV3): """A layer over other storage, where the metadata has been consolidated into a single key. @@ -580,6 +620,9 @@ def rmdir(self, key): raise ReadOnlyError() +@deprecated( + "This implementation of Zarr V3 is out of date and will be supplanted in zarr-python 3.0" +) def _normalize_store_arg_v3(store: Any, storage_options=None, mode="r") -> BaseStore: # default to v2 store for backward compatibility zarr_version = getattr(store, "_store_version", 3) diff --git a/src/zarr/_storage/v3_storage_transformers.py b/src/zarr/_storage/v3_storage_transformers.py index 3090aea28..dd49b8de3 100644 --- a/src/zarr/_storage/v3_storage_transformers.py +++ b/src/zarr/_storage/v3_storage_transformers.py @@ -2,6 +2,7 @@ import itertools import os from typing import NamedTuple, Tuple, Optional, Union, Iterator +from typing_extensions import deprecated from numcodecs.compat import ensure_bytes import numpy as np @@ -97,6 +98,9 @@ def __init__(self, _type, test_value) -> None: self.test_value = test_value +@deprecated( + "This implementation of Zarr V3 is out of date and will be supplanted in zarr-python 3.0" +) class ShardingStorageTransformer(StorageTransformer): # lgtm[py/missing-equals] """Implements sharding as a storage transformer, as described in the spec: https://zarr-specs.readthedocs.io/en/latest/extensions/storage-transformers/sharding/v1.0.html diff --git a/src/zarr/meta.py b/src/zarr/meta.py index bd1f4ee03..939d882f4 100644 --- a/src/zarr/meta.py +++ b/src/zarr/meta.py @@ -1,6 +1,7 @@ import base64 import itertools from collections.abc import Mapping +from typing_extensions import deprecated import numcodecs import numpy as np @@ -302,6 +303,9 @@ def encode_fill_value(cls, v: Any, dtype: np.dtype, object_codec: Any = None) -> return v +@deprecated( + "This implementation of Zarr V3 is out of date and will be supplanted in zarr-python 3.0" +) class Metadata3(Metadata2): ZARR_FORMAT = ZARR_FORMAT_v3