Skip to content

Deprecate v3 code on v2 branch #2873

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/minimal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ jobs:
- name: Tests
shell: "bash -l {0}"
env:
ZARR_V3_EXPERIMENTAL_API: 1
ZARR_V3_SHARDING: 1
ZARR_V3_EXPERIMENTAL_API: 0
ZARR_V3_SHARDING: 0
run: |
conda activate minimal
python -m pip install .
pytest -svx --timeout=300
- name: Fixture generation
shell: "bash -l {0}"
env:
ZARR_V3_EXPERIMENTAL_API: 1
ZARR_V3_SHARDING: 1
ZARR_V3_EXPERIMENTAL_API: 0
ZARR_V3_SHARDING: 0
run: |
conda activate minimal
rm -rf fixture/
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ jobs:
ZARR_TEST_ABS: 1
ZARR_TEST_MONGO: 1
ZARR_TEST_REDIS: 1
ZARR_V3_EXPERIMENTAL_API: 1
ZARR_V3_SHARDING: 1
ZARR_V3_EXPERIMENTAL_API: 0
ZARR_V3_SHARDING: 0
run: |
conda activate zarr-env
mkdir ~/blob_emulator
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/windows-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ jobs:
pytest -sv --timeout=300
env:
ZARR_TEST_ABS: 1
ZARR_V3_EXPERIMENTAL_API: 1
ZARR_V3_SHARDING: 1
ZARR_V3_EXPERIMENTAL_API: 0
ZARR_V3_SHARDING: 0
- name: Conda info
shell: bash -l {0}
run: conda info
Expand Down
4 changes: 4 additions & 0 deletions docs/release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ Unreleased
Deprecations
~~~~~~~~~~~~

* Deprecated ``zarr._storage.v3`` and ``zarr._storage.v3_storage_transformers``.
This functionality and will be removed in ``zarr-python`` 2.19.0.
For Zarr format 3 support, use the v3 release of ``zarr-python``.
By :user:`David Stansby <dstansby>`
* Deprecated support for ``partial_decompress`` when creating an array.
This functionality is no longer supported in ``numcodecs``, and will be removed
in ``zarr-python`` 2.19.0.
Expand Down
7 changes: 7 additions & 0 deletions zarr/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# flake8: noqa
import warnings
from zarr.codecs import *
from zarr.convenience import (
consolidate_metadata,
Expand Down Expand Up @@ -55,6 +56,12 @@
assert not __version__.startswith("0.0.0")

if v3_api_available:
warnings.warn(

Check warning on line 59 in zarr/__init__.py

View check run for this annotation

Codecov / codecov/patch

zarr/__init__.py#L59

Added line #L59 was not covered by tests
"The zarr v3 API in zarr-python v2 is deprecated, and will be removed in zarr-python 2.19.0. "
"Use zarr-python 3 instead for Zarr format 3 support.",
DeprecationWarning,
stacklevel=2,
)
from zarr._storage.v3 import (
ABSStoreV3,
DBMStoreV3,
Expand Down
11 changes: 11 additions & 0 deletions zarr/_storage/v3.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import warnings


import os
import shutil
from collections import OrderedDict
Expand Down Expand Up @@ -49,6 +52,14 @@
_getsize,
)

warnings.warn(
"zarr._storage.v3 is deprecated, and will be removed in zarr-python 2.19.0. "
"Use zarr-python 3 instead for Zarr format 3 support.",
DeprecationWarning,
stacklevel=2,
)


__doctest_requires__ = {
("RedisStore", "RedisStore.*"): ["redis"],
("MongoDBStore", "MongoDBStore.*"): ["pymongo"],
Expand Down
9 changes: 9 additions & 0 deletions zarr/_storage/v3_storage_transformers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import itertools
import os
from typing import NamedTuple, Tuple, Optional, Union, Iterator
import warnings

from numcodecs.compat import ensure_bytes
import numpy as np
Expand All @@ -11,6 +12,14 @@
from zarr.types import DIMENSION_SEPARATOR


warnings.warn(
"zarr._storage.v3 is deprecated, and will be removed in zarr-python 2.19.0. "
"Use zarr-python 3 instead for Zarr format 3 support.",
DeprecationWarning,
stacklevel=2,
)


MAX_UINT_64 = 2**64 - 1


Expand Down
6 changes: 5 additions & 1 deletion zarr/convenience.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@
BaseStore,
ConsolidatedMetadataStore,
)
from zarr._storage.v3 import ConsolidatedMetadataStoreV3
from zarr._storage.store import v3_api_available

if v3_api_available:
from zarr._storage.v3 import ConsolidatedMetadataStoreV3

Check warning on line 28 in zarr/convenience.py

View check run for this annotation

Codecov / codecov/patch

zarr/convenience.py#L28

Added line #L28 was not covered by tests

from zarr.util import TreeViewer, buffer_size, normalize_storage_path

from typing import Union
Expand Down
40 changes: 25 additions & 15 deletions zarr/hierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@
rename,
rmdir,
)
from zarr._storage.v3 import MemoryStoreV3
from zarr._storage.store import v3_api_available

if v3_api_available:
from zarr._storage.v3 import MemoryStoreV3

Check warning on line 52 in zarr/hierarchy.py

View check run for this annotation

Codecov / codecov/patch

zarr/hierarchy.py#L52

Added line #L52 was not covered by tests

from zarr.util import (
InfoReporter,
TreeViewer,
Expand Down Expand Up @@ -609,27 +613,33 @@
for key in sorted(listdir(self._store, self._path)):
path = self._key_prefix + key
if contains_group(self._store, path, explicit_only=False):
yield key, Group(
yield (
key,
Group(
self._store,
path=path,
read_only=self._read_only,
chunk_store=self._chunk_store,
cache_attrs=self.attrs.cache,
synchronizer=self._synchronizer,
zarr_version=self._version,
),
)

else:
for key in self.group_keys():
path = self._key_prefix + key
yield (

Check warning on line 632 in zarr/hierarchy.py

View check run for this annotation

Codecov / codecov/patch

zarr/hierarchy.py#L630-L632

Added lines #L630 - L632 were not covered by tests
key,
Group(
self._store,
path=path,
read_only=self._read_only,
chunk_store=self._chunk_store,
cache_attrs=self.attrs.cache,
synchronizer=self._synchronizer,
zarr_version=self._version,
)

else:
for key in self.group_keys():
path = self._key_prefix + key
yield key, Group(
self._store,
path=path,
read_only=self._read_only,
chunk_store=self._chunk_store,
cache_attrs=self.attrs.cache,
synchronizer=self._synchronizer,
zarr_version=self._version,
),
)

def array_keys(self, recurse=False):
Expand Down
19 changes: 10 additions & 9 deletions zarr/tests/test_attrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,22 @@
from zarr._storage.store import meta_root
from zarr.attrs import Attributes
from zarr.storage import KVStore, DirectoryStore
from zarr._storage.v3 import KVStoreV3
from zarr.tests.util import CountingDict, CountingDictV3


from zarr.tests.util import CountingDict
from zarr.hierarchy import group

pytestmark = pytest.mark.filterwarnings("ignore:zarr.*v3 is deprecated:DeprecationWarning")

@pytest.fixture(params=[2, 3])

@pytest.fixture(params=[2])
def zarr_version(request):
return request.param


def _init_store(version):
"""Use a plain dict() for v2, but KVStoreV3 otherwise."""
if version == 2:
return dict()
return KVStoreV3(dict())
return dict()


class TestAttributes:
Expand Down Expand Up @@ -154,8 +155,8 @@ def test_caching_on(self, zarr_version):
# caching is turned on by default

# setup store
store = CountingDict() if zarr_version == 2 else CountingDictV3()
attrs_key = ".zattrs" if zarr_version == 2 else "meta/root/attrs"
store = CountingDict()
attrs_key = ".zattrs"
assert 0 == store.counter["__getitem__", attrs_key]
assert 0 == store.counter["__setitem__", attrs_key]
if zarr_version == 2:
Expand Down Expand Up @@ -228,7 +229,7 @@ def test_caching_on(self, zarr_version):

def test_caching_off(self, zarr_version):
# setup store
store = CountingDict() if zarr_version == 2 else CountingDictV3()
store = CountingDict()
attrs_key = ".zattrs" if zarr_version == 2 else "meta/root/attrs"
assert 0 == store.counter["__getitem__", attrs_key]
assert 0 == store.counter["__setitem__", attrs_key]
Expand Down
Loading
Loading