Skip to content

Commit 8a20c68

Browse files
committed
Add , remove accidental print
1 parent 4270159 commit 8a20c68

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
@@ -3476,12 +3476,21 @@ async def _read_metadata_v2(store: Store, path: str) -> ArrayV2Metadata | GroupM
34763476
"""
34773477
# TODO: consider first fetching array metadata, and only fetching group metadata when we don't
34783478
# find an array
3479-
print(f"Reading metadata from {path} in store {store}", file=sys.stderr)
3480-
zarray_bytes, zgroup_bytes, zattrs_bytes = await asyncio.gather(
3481-
store.get(_join_paths([path, ZARRAY_JSON]), prototype=default_buffer_prototype()),
3482-
store.get(_join_paths([path, ZGROUP_JSON]), prototype=default_buffer_prototype()),
3483-
store.get(_join_paths([path, ZATTRS_JSON]), prototype=default_buffer_prototype()),
3484-
)
3479+
requests = [
3480+
(_join_paths([path, ZARRAY_JSON]), default_buffer_prototype(), None),
3481+
(_join_paths([path, ZGROUP_JSON]), default_buffer_prototype(), None),
3482+
(_join_paths([path, ZATTRS_JSON]), default_buffer_prototype(), None),
3483+
]
3484+
3485+
# Use the _get_many method to retrieve the data
3486+
results = {}
3487+
async for key, buffer in store._get_many(requests):
3488+
results[key] = buffer
3489+
3490+
zarray_bytes = results.get(_join_paths([path, ZARRAY_JSON]))
3491+
zgroup_bytes = results.get(_join_paths([path, ZGROUP_JSON]))
3492+
zattrs_bytes = results.get(_join_paths([path, ZATTRS_JSON]))
3493+
34853494
if zattrs_bytes is None:
34863495
zattrs = {}
34873496
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)