Skip to content

Commit 59cf72a

Browse files
committed
fix
1 parent 6d44577 commit 59cf72a

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/pyXenium/io/partial_xenium_loader.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,16 +156,25 @@ def has(pfx: str, fname: str) -> bool:
156156
def _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

0 commit comments

Comments
 (0)