Skip to content

Commit

Permalink
chore: add deprecation warnings to v3 classes / functions
Browse files Browse the repository at this point in the history
  • Loading branch information
d-v-b committed Apr 4, 2024
1 parent 76c3450 commit 4b20501
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 0 deletions.
4 changes: 4 additions & 0 deletions 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
Expand Down Expand Up @@ -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())
Expand Down
20 changes: 20 additions & 0 deletions src/zarr/_storage/store.py
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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."""
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
43 changes: 43 additions & 0 deletions src/zarr/_storage/v3.py
Expand Up @@ -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,
Expand Down Expand Up @@ -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."""

Expand All @@ -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())
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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())
Expand All @@ -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())
Expand All @@ -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())
Expand All @@ -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())
Expand All @@ -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())
Expand Down Expand Up @@ -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)
Expand All @@ -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.
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions src/zarr/_storage/v3_storage_transformers.py
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions 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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 4b20501

Please sign in to comment.