Skip to content

Commit cd7bd60

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 f5cb80c commit cd7bd60

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

xarray/backends/zarr.py

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

22752275

22762276
async def _iter_zarr_groups_async(root: ZarrGroup, parent: str = "/") -> list[str]:
2277-
from zarr.core.group import AsyncGroup
2277+
try:
2278+
from zarr.core.group import AsyncGroup
2279+
except (ImportError, ModuleNotFoundError):
2280+
# zarr v2: no async group support, fall back to sync
2281+
return list(_iter_zarr_groups(root, parent=parent))
22782282

22792283
parent_nodepath = NodePath(parent)
22802284
group_paths = [str(parent_nodepath)]

0 commit comments

Comments
 (0)