File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed
Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -156,16 +156,25 @@ def has(pfx: str, fname: str) -> bool:
156156def _open_zarr_zip (zip_path : str ):
157157 """Open a zipped Zarr (v2 or v3) **without extraction** and return a zarr Group.
158158 The Zarr root may be inside a subfolder of the ZIP.
159+ Uses zarr.storage.ZipStore to avoid fsspec path quirks in certain envs.
159160 """
161+ if os .path .isdir (zip_path ):
162+ raise IsADirectoryError (f"Expected a .zip file, got directory: { zip_path } " )
163+
160164 root_prefix , zv = _find_zarr_root_in_zip (zip_path )
161- mapper = fsspec .get_mapper (f"zip://{ zip_path } " )
162- # zarr.open_group works for both v2/v3 stores; specify path when non-root
165+
166+ # Prefer ZipStore for local file paths; it's robust and avoids cwd confusion
167+ try :
168+ store = zarr .storage .ZipStore (zip_path , mode = "r" )
169+ except Exception as e :
170+ raise RuntimeError (f"Failed to open ZipStore for { zip_path } : { e } " ) from e
171+
163172 path = root_prefix .rstrip ('/' )
164173 try :
165- grp = zarr .open_group (store = mapper , path = path , mode = "r" )
174+ grp = zarr .open_group (store = store , path = path , mode = "r" )
166175 except TypeError :
167176 # very old zarr fallback
168- grp = zarr .open_group (mapper , mode = "r" )
177+ grp = zarr .open_group (store , mode = "r" )
169178 if path :
170179 grp = grp [path ]
171180 return grp
You can’t perform that action at this time.
0 commit comments