Skip to content

Commit 943715e

Browse files
committed
Fix zarr v2 fallback in _iter_zarr_groups_async
Add try/except around zarr.core.group import so zarr v2 (where zarr.core is a module, not a package) falls back to sync discovery.
1 parent d285a56 commit 943715e

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

xarray/backends/zarr.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2266,7 +2266,11 @@ def _iter_zarr_groups(root: ZarrGroup, parent: str = "/") -> Iterable[str]:
22662266

22672267

22682268
async def _iter_zarr_groups_async(root: ZarrGroup, parent: str = "/") -> list[str]:
2269-
from zarr.core.group import AsyncGroup
2269+
try:
2270+
from zarr.core.group import AsyncGroup
2271+
except (ImportError, ModuleNotFoundError):
2272+
# zarr v2: no async group support, fall back to sync
2273+
return list(_iter_zarr_groups(root, parent=parent))
22702274

22712275
parent_nodepath = NodePath(parent)
22722276
group_paths = [str(parent_nodepath)]

0 commit comments

Comments
 (0)