Skip to content

Commit cbfc197

Browse files
committed
Merge remote-tracking branch 'upstream/v3' into tom/fix/cm-nested-getitem
2 parents 488d57f + 840a3f7 commit cbfc197

File tree

9 files changed

+35
-25
lines changed

9 files changed

+35
-25
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ ci:
22
autoupdate_commit_msg: "chore: update pre-commit hooks"
33
autofix_commit_msg: "style: pre-commit fixes"
44
autofix_prs: false
5-
default_stages: [commit, push]
5+
default_stages: [pre-commit, pre-push]
66
default_language_version:
77
python: python3
88
repos:

docs/_static/custom.css

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
@import url('https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,400;0,700;0,900;1,400;1,700;1,900&family=Open+Sans:ital,wght@0,400;0,600;1,400;1,600&display=swap');
22

3-
.navbar-brand img {
4-
height: 75px;
5-
}
6-
.navbar-brand {
7-
height: 75px;
8-
}
9-
103
body {
114
font-family: 'Open Sans', sans-serif;
125
}

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ gpu = [
7878
"cupy-cuda12x",
7979
]
8080
docs = [
81-
'sphinx==8.0.2',
81+
'sphinx==8.1.3',
8282
'sphinx-autobuild>=2021.3.14',
8383
'sphinx-autoapi==3.3.2',
8484
'sphinx_design',

src/zarr/abc/store.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22

33
from abc import ABC, abstractmethod
44
from asyncio import gather
5-
from collections.abc import AsyncGenerator, Iterable
65
from types import TracebackType
7-
from typing import TYPE_CHECKING, Any, NamedTuple, Protocol, runtime_checkable
6+
from typing import TYPE_CHECKING, NamedTuple, Protocol, runtime_checkable
87

98
if TYPE_CHECKING:
109
from collections.abc import AsyncGenerator, Iterable

src/zarr/api/asynchronous.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
from zarr.abc.store import Store
1212
from zarr.core.array import Array, AsyncArray, get_array_metadata
13-
from zarr.core.buffer import NDArrayLike
14-
from zarr.core.chunk_key_encodings import ChunkKeyEncoding
1513
from zarr.core.common import (
1614
JSON,
1715
AccessModeLiteral,

src/zarr/core/group.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import itertools
55
import json
66
import logging
7+
import warnings
78
from collections import defaultdict
89
from dataclasses import asdict, dataclass, field, fields, replace
910
from typing import TYPE_CHECKING, Literal, TypeVar, assert_never, cast, overload
@@ -1207,7 +1208,8 @@ async def _members(
12071208
raise ValueError(msg)
12081209
# would be nice to make these special keys accessible programmatically,
12091210
# and scoped to specific zarr versions
1210-
_skip_keys = ("zarr.json", ".zgroup", ".zattrs")
1211+
# especially true for `.zmetadata` which is configurable
1212+
_skip_keys = ("zarr.json", ".zgroup", ".zattrs", ".zmetadata")
12111213

12121214
# hmm lots of I/O and logic interleaved here.
12131215
# We *could* have an async gen over self.metadata.consolidated_metadata.metadata.keys()
@@ -1237,9 +1239,10 @@ async def _members(
12371239
# keyerror is raised when `key` names an object (in the object storage sense),
12381240
# as opposed to a prefix, in the store under the prefix associated with this group
12391241
# in which case `key` cannot be the name of a sub-array or sub-group.
1240-
logger.warning(
1241-
"Object at %s is not recognized as a component of a Zarr hierarchy.",
1242-
key,
1242+
warnings.warn(
1243+
f"Object at {key} is not recognized as a component of a Zarr hierarchy.",
1244+
UserWarning,
1245+
stacklevel=1,
12431246
)
12441247

12451248
def _members_consolidated(

src/zarr/storage/logging.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from typing import TYPE_CHECKING, Any, Self
99

1010
from zarr.abc.store import AccessMode, ByteRangeRequest, Store
11-
from zarr.core.buffer import Buffer
1211

1312
if TYPE_CHECKING:
1413
from collections.abc import AsyncGenerator, Generator, Iterable

tests/v3/test_group.py

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
from __future__ import annotations
22

3+
import contextlib
34
import pickle
5+
import warnings
46
from typing import TYPE_CHECKING, Any, Literal, cast
57

68
import numpy as np
@@ -177,22 +179,33 @@ def test_group_members(store: Store, zarr_format: ZarrFormat, consolidated_metad
177179
)
178180
)
179181

182+
# this warning shows up when extra objects show up in the hierarchy
183+
warn_context = pytest.warns(
184+
UserWarning, match=r"Object at .* is not recognized as a component of a Zarr hierarchy."
185+
)
180186
if consolidated_metadata:
181-
zarr.consolidate_metadata(store=store, zarr_format=zarr_format)
187+
with warn_context:
188+
zarr.consolidate_metadata(store=store, zarr_format=zarr_format)
189+
# now that we've consolidated the store, we shouldn't get the warnings from the unrecognized objects anymore
190+
# we use a nullcontext to handle these cases
191+
warn_context = contextlib.nullcontext()
182192
group = zarr.open_consolidated(store=store, zarr_format=zarr_format)
183193

184-
members_observed = group.members()
194+
with warn_context:
195+
members_observed = group.members()
185196
# members are not guaranteed to be ordered, so sort before comparing
186197
assert sorted(dict(members_observed)) == sorted(members_expected)
187198

188199
# partial
189-
members_observed = group.members(max_depth=1)
200+
with warn_context:
201+
members_observed = group.members(max_depth=1)
190202
members_expected["subgroup/subsubgroup"] = subsubgroup
191203
# members are not guaranteed to be ordered, so sort before comparing
192204
assert sorted(dict(members_observed)) == sorted(members_expected)
193205

194206
# total
195-
members_observed = group.members(max_depth=None)
207+
with warn_context:
208+
members_observed = group.members(max_depth=None)
196209
members_expected["subgroup/subsubgroup/subsubsubgroup"] = subsubsubgroup
197210
# members are not guaranteed to be ordered, so sort before comparing
198211
assert sorted(dict(members_observed)) == sorted(members_expected)
@@ -1137,8 +1150,8 @@ async def test_require_array(store: Store, zarr_format: ZarrFormat) -> None:
11371150

11381151

11391152
@pytest.mark.parametrize("consolidate", [True, False])
1140-
def test_members_name(store: Store, consolidate: bool):
1141-
group = Group.from_store(store=store)
1153+
async def test_members_name(store: Store, consolidate: bool, zarr_format: ZarrFormat):
1154+
group = Group.from_store(store=store, zarr_format=zarr_format)
11421155
a = group.create_group(name="a")
11431156
a.create_array("array", shape=(1,))
11441157
b = a.create_group(name="b")
@@ -1154,6 +1167,12 @@ def test_members_name(store: Store, consolidate: bool):
11541167
expected = ["/a", "/a/array", "/a/b", "/a/b/array"]
11551168
assert paths == expected
11561169

1170+
# regression test for https://github.com/zarr-developers/zarr-python/pull/2356
1171+
g = zarr.open_group(store, use_consolidated=False)
1172+
with warnings.catch_warnings():
1173+
warnings.simplefilter("error")
1174+
assert list(g)
1175+
11571176

11581177
async def test_open_mutable_mapping():
11591178
group = await zarr.api.asynchronous.open_group(store={}, mode="w")

tests/v3/test_indexing.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1769,7 +1769,6 @@ async def test_accessed_chunks(
17691769
# chunks: chunk size
17701770
# ops: list of tuples with (optype, tuple of slices)
17711771
# optype = "__getitem__" or "__setitem__", tuple length must match number of dims
1772-
import itertools
17731772

17741773
# Use a counting dict as the backing store so we can track the items access
17751774
store = await CountingDict.open()

0 commit comments

Comments
 (0)