Skip to content

Commit 748e26a

Browse files
committed
Add , remove accidental print
1 parent de7434a commit 748e26a

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

src/zarr/core/group.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3453,12 +3453,21 @@ async def _read_metadata_v2(store: Store, path: str) -> ArrayV2Metadata | GroupM
34533453
"""
34543454
# TODO: consider first fetching array metadata, and only fetching group metadata when we don't
34553455
# find an array
3456-
print(f"Reading metadata from {path} in store {store}", file=sys.stderr)
3457-
zarray_bytes, zgroup_bytes, zattrs_bytes = await asyncio.gather(
3458-
store.get(_join_paths([path, ZARRAY_JSON]), prototype=default_buffer_prototype()),
3459-
store.get(_join_paths([path, ZGROUP_JSON]), prototype=default_buffer_prototype()),
3460-
store.get(_join_paths([path, ZATTRS_JSON]), prototype=default_buffer_prototype()),
3461-
)
3456+
requests = [
3457+
(_join_paths([path, ZARRAY_JSON]), default_buffer_prototype(), None),
3458+
(_join_paths([path, ZGROUP_JSON]), default_buffer_prototype(), None),
3459+
(_join_paths([path, ZATTRS_JSON]), default_buffer_prototype(), None),
3460+
]
3461+
3462+
# Use the _get_many method to retrieve the data
3463+
results = {}
3464+
async for key, buffer in store._get_many(requests):
3465+
results[key] = buffer
3466+
3467+
zarray_bytes = results.get(_join_paths([path, ZARRAY_JSON]))
3468+
zgroup_bytes = results.get(_join_paths([path, ZGROUP_JSON]))
3469+
zattrs_bytes = results.get(_join_paths([path, ZATTRS_JSON]))
3470+
34623471
if zattrs_bytes is None:
34633472
zattrs = {}
34643473
else:

src/zarr/storage/_fsspec.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from zarr.storage._common import _dereference_path
1919

2020
if TYPE_CHECKING:
21-
from collections.abc import AsyncIterator, Iterable
21+
from collections.abc import AsyncGenerator, AsyncIterator, Iterable
2222

2323
from fsspec import AbstractFileSystem
2424
from fsspec.asyn import AsyncFileSystem
@@ -326,6 +326,17 @@ async def get(
326326
else:
327327
return value
328328

329+
async def _get_many(
330+
self, requests: Iterable[tuple[str, BufferPrototype, ByteRequest | None]]
331+
) -> AsyncGenerator[tuple[str, Buffer | None], None]:
332+
if getattr(self.fs, "asynchronous", True):
333+
async for result in super()._get_many(requests=requests):
334+
yield result
335+
else:
336+
for key, prototype, byte_range in requests:
337+
value = await self.get(key, prototype, byte_range)
338+
yield (key, value)
339+
329340
async def set(
330341
self,
331342
key: str,

0 commit comments

Comments
 (0)