Skip to content

Commit 6a55eae

Browse files
authored
Merge branch 'main' into order-handling
2 parents a79747b + 7a162bf commit 6a55eae

File tree

12 files changed

+57
-55
lines changed

12 files changed

+57
-55
lines changed

.github/ISSUE_TEMPLATE/release-checklist.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ assignees: ''
2525
- [ ] All tests pass in the ["GPU Tests" workflow](https://github.com/zarr-developers/zarr-python/actions/workflows/gpu_test.yml).
2626
- [ ] All tests pass in the ["Hypothesis" workflow](https://github.com/zarr-developers/zarr-python/actions/workflows/hypothesis.yaml).
2727
- [ ] Check that downstream libraries work well (maintainers can make executive decisions about whether all checks are required for this release).
28+
- [ ] numcodecs
2829
- [ ] Xarray (@jhamman @dcherian @TomNicholas)
2930
- Zarr's upstream compatibility is tested via the [Upstream Dev CI worklow](https://github.com/pydata/xarray/actions/workflows/upstream-dev-ci.yaml).
3031
- Click on the most recent workflow and check that the `upstream-dev` job has run and passed. `upstream-dev` is not run on all all workflow runs.

changes/3227.feature.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add lightweight implementations of .getsize() and .getsize_prefix() for ObjectStore.

changes/3268.misc.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Removed warnings that were emitted when using the ``vlen-utf8`` and ``vlen-bytes`` codecs. Those
2+
warnings are no longer needed now that both of these codecs are backed by specification documents.

docs/about.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Funding
1818
-------
1919
The project is fiscally sponsored by `NumFOCUS <https://numfocus.org/>`_, a US
2020
501(c)(3) public charity, and development is supported by the
21-
`MRC Centre for Genomics and Global Health <https://www.cggh.org>`_
21+
`MRC Centre for Genomics and Global Health <https://github.com/cggh/>`_
2222
and the `Chan Zuckerberg Initiative <https://chanzuckerberg.com/>`_.
2323

2424
.. _NumCodecs: https://numcodecs.readthedocs.io/

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,6 @@ extend-select = [
324324
ignore = [
325325
"ANN401",
326326
"PT011", # TODO: apply this rule
327-
"PT012", # TODO: apply this rule
328327
"PT030", # TODO: apply this rule
329328
"PT031", # TODO: apply this rule
330329
"RET505",

src/zarr/codecs/vlen_utf8.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
from dataclasses import dataclass
44
from typing import TYPE_CHECKING
5-
from warnings import warn
65

76
import numpy as np
87
from numcodecs.vlen import VLenBytes, VLenUTF8
@@ -25,15 +24,6 @@
2524

2625
@dataclass(frozen=True)
2726
class VLenUTF8Codec(ArrayBytesCodec):
28-
def __init__(self) -> None:
29-
warn(
30-
"The codec `vlen-utf8` is currently not part in the Zarr format 3 specification. It "
31-
"may not be supported by other zarr implementations and may change in the future.",
32-
category=UserWarning,
33-
stacklevel=2,
34-
)
35-
super().__init__()
36-
3727
@classmethod
3828
def from_dict(cls, data: dict[str, JSON]) -> Self:
3929
_, configuration_parsed = parse_named_configuration(
@@ -80,15 +70,6 @@ def compute_encoded_size(self, input_byte_length: int, _chunk_spec: ArraySpec) -
8070

8171
@dataclass(frozen=True)
8272
class VLenBytesCodec(ArrayBytesCodec):
83-
def __init__(self) -> None:
84-
warn(
85-
"The codec `vlen-bytes` is currently not part in the Zarr format 3 specification. It "
86-
"may not be supported by other zarr implementations and may change in the future.",
87-
category=UserWarning,
88-
stacklevel=2,
89-
)
90-
super().__init__()
91-
9273
@classmethod
9374
def from_dict(cls, data: dict[str, JSON]) -> Self:
9475
_, configuration_parsed = parse_named_configuration(

src/zarr/storage/_obstore.py

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -212,19 +212,21 @@ def supports_listing(self) -> bool:
212212
# docstring inherited
213213
return True
214214

215-
def list(self) -> AsyncGenerator[str, None]:
216-
# docstring inherited
215+
async def _list(self, prefix: str | None = None) -> AsyncGenerator[ObjectMeta, None]:
217216
import obstore as obs
218217

219-
objects: ListStream[Sequence[ObjectMeta]] = obs.list(self.store)
220-
return _transform_list(objects)
218+
objects: ListStream[Sequence[ObjectMeta]] = obs.list(self.store, prefix=prefix)
219+
async for batch in objects:
220+
for item in batch:
221+
yield item
221222

222-
def list_prefix(self, prefix: str) -> AsyncGenerator[str, None]:
223+
def list(self) -> AsyncGenerator[str, None]:
223224
# docstring inherited
224-
import obstore as obs
225+
return (obj["path"] async for obj in self._list())
225226

226-
objects: ListStream[Sequence[ObjectMeta]] = obs.list(self.store, prefix=prefix)
227-
return _transform_list(objects)
227+
def list_prefix(self, prefix: str) -> AsyncGenerator[str, None]:
228+
# docstring inherited
229+
return (obj["path"] async for obj in self._list(prefix))
228230

229231
def list_dir(self, prefix: str) -> AsyncGenerator[str, None]:
230232
# docstring inherited
@@ -233,21 +235,21 @@ def list_dir(self, prefix: str) -> AsyncGenerator[str, None]:
233235
coroutine = obs.list_with_delimiter_async(self.store, prefix=prefix)
234236
return _transform_list_dir(coroutine, prefix)
235237

238+
async def getsize(self, key: str) -> int:
239+
# docstring inherited
240+
import obstore as obs
236241

237-
async def _transform_list(
238-
list_stream: ListStream[Sequence[ObjectMeta]],
239-
) -> AsyncGenerator[str, None]:
240-
"""
241-
Transform the result of list into an async generator of paths.
242-
"""
243-
async for batch in list_stream:
244-
for item in batch:
245-
yield item["path"]
242+
resp = await obs.head_async(self.store, key)
243+
return resp["size"]
244+
245+
async def getsize_prefix(self, prefix: str) -> int:
246+
# docstring inherited
247+
sizes = [obj["size"] async for obj in self._list(prefix=prefix)]
248+
return sum(sizes)
246249

247250

248251
async def _transform_list_dir(
249-
list_result_coroutine: Coroutine[Any, Any, ListResult[Sequence[ObjectMeta]]],
250-
prefix: str,
252+
list_result_coroutine: Coroutine[Any, Any, ListResult[Sequence[ObjectMeta]]], prefix: str
251253
) -> AsyncGenerator[str, None]:
252254
"""
253255
Transform the result of list_with_delimiter into an async generator of paths.

tests/test_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,9 @@ def test_save_errors() -> None:
261261
with pytest.raises(ValueError):
262262
# no arrays provided
263263
save("data/group.zarr")
264+
a = np.arange(10)
264265
with pytest.raises(TypeError):
265266
# mode is no valid argument and would get handled as an array
266-
a = np.arange(10)
267267
zarr.save("data/example.zarr", a, mode="w")
268268

269269

tests/test_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ async def write(
141141

142142
_mock.call.assert_called()
143143

144+
config.set({"codec_pipeline.path": "wrong_name"})
144145
with pytest.raises(BadConfigError):
145-
config.set({"codec_pipeline.path": "wrong_name"})
146146
get_pipeline_class()
147147

148148
class MockEnvCodecPipeline(CodecPipeline):

tests/test_group.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -655,12 +655,13 @@ def test_group_create_array(
655655

656656
if not overwrite:
657657
if method == "create_array":
658-
with pytest.raises(ContainsArrayError):
658+
with pytest.raises(ContainsArrayError): # noqa: PT012
659659
a = group.create_array(name=name, shape=shape, dtype=dtype)
660660
a[:] = data
661661
elif method == "array":
662-
with pytest.raises(ContainsArrayError), pytest.warns(DeprecationWarning):
663-
a = group.array(name=name, shape=shape, dtype=dtype)
662+
with pytest.raises(ContainsArrayError): # noqa: PT012
663+
with pytest.warns(DeprecationWarning):
664+
a = group.array(name=name, shape=shape, dtype=dtype)
664665
a[:] = data
665666

666667
assert array.path == normalize_path(name)

0 commit comments

Comments
 (0)