@@ -513,19 +513,23 @@ async def open(
513
513
consolidated_key = use_consolidated
514
514
515
515
if zarr_format == 2 :
516
- paths = [store_path / ZGROUP_JSON , store_path / ZATTRS_JSON ]
516
+ requests = [
517
+ (key , default_buffer_prototype (), None ) for key in [ZGROUP_JSON , ZATTRS_JSON ]
518
+ ]
517
519
if use_consolidated or use_consolidated is None :
518
- paths .append (store_path / consolidated_key )
520
+ requests .append (( consolidated_key , default_buffer_prototype (), None ) )
519
521
520
- zgroup_bytes , zattrs_bytes , * rest = await asyncio .gather (
521
- * [path .get () for path in paths ]
522
+ retrieved_buffers = {key : value async for key , value in store_path .get_many (requests )}
523
+ zgroup_bytes , zattrs_bytes = (
524
+ retrieved_buffers [ZGROUP_JSON ],
525
+ retrieved_buffers [ZATTRS_JSON ],
522
526
)
527
+
523
528
if zgroup_bytes is None :
524
529
raise FileNotFoundError (store_path )
525
530
526
531
if use_consolidated or use_consolidated is None :
527
- maybe_consolidated_metadata_bytes = rest [0 ]
528
-
532
+ maybe_consolidated_metadata_bytes = retrieved_buffers [consolidated_key ]
529
533
else :
530
534
maybe_consolidated_metadata_bytes = None
531
535
@@ -534,17 +538,18 @@ async def open(
534
538
if zarr_json_bytes is None :
535
539
raise FileNotFoundError (store_path )
536
540
elif zarr_format is None :
541
+ requests = [
542
+ (key , default_buffer_prototype (), None )
543
+ for key in [ZARR_JSON , ZGROUP_JSON , ZATTRS_JSON , consolidated_key ]
544
+ ]
545
+ retrieved_buffers = {key : value async for key , value in store_path .get_many (requests )}
537
546
(
538
547
zarr_json_bytes ,
539
548
zgroup_bytes ,
540
549
zattrs_bytes ,
541
550
maybe_consolidated_metadata_bytes ,
542
- ) = await store_path .get_many_ordered (
543
- ZARR_JSON ,
544
- ZGROUP_JSON ,
545
- ZATTRS_JSON ,
546
- consolidated_key ,
547
- )
551
+ ) = tuple (retrieved_buffers .get (req [0 ]) for req in requests )
552
+
548
553
if zarr_json_bytes is not None and zgroup_bytes is not None :
549
554
# warn and favor v3
550
555
msg = f"Both zarr.json (Zarr format 3) and .zgroup (Zarr format 2) metadata objects exist at { store_path } . Zarr format 3 will be used."
@@ -3476,12 +3481,14 @@ async def _read_metadata_v2(store: Store, path: str) -> ArrayV2Metadata | GroupM
3476
3481
"""
3477
3482
# TODO: consider first fetching array metadata, and only fetching group metadata when we don't
3478
3483
# find an array
3479
- zarray_bytes , zgroup_bytes , zattrs_bytes = await store ._get_many_ordered (
3480
- [
3481
- (_join_paths ([path , ZARRAY_JSON ]), default_buffer_prototype (), None ),
3482
- (_join_paths ([path , ZGROUP_JSON ]), default_buffer_prototype (), None ),
3483
- (_join_paths ([path , ZATTRS_JSON ]), default_buffer_prototype (), None ),
3484
- ]
3484
+ requests = [
3485
+ (_join_paths ([path , ZARRAY_JSON ]), default_buffer_prototype (), None ),
3486
+ (_join_paths ([path , ZGROUP_JSON ]), default_buffer_prototype (), None ),
3487
+ (_join_paths ([path , ZATTRS_JSON ]), default_buffer_prototype (), None ),
3488
+ ]
3489
+ retrieved_buffers = {key : value async for key , value in store ._get_many (requests )}
3490
+ zarray_bytes , zgroup_bytes , zattrs_bytes = tuple (
3491
+ retrieved_buffers .get (req [0 ]) for req in requests
3485
3492
)
3486
3493
3487
3494
if zattrs_bytes is None :
0 commit comments