@@ -60,10 +60,6 @@ def _open_store(
6060 version : Literal ["0.1" , "0.4" ],
6161 synchronizer = None ,
6262):
63- if not os .path .isdir (store_path ) and mode in ("r" , "r+" ):
64- raise FileNotFoundError (
65- f"Dataset directory not found at { store_path } ."
66- )
6763 if version != "0.4" :
6864 _logger .warning (
6965 "IOHub is only tested against OME-NGFF v0.4. "
@@ -77,6 +73,13 @@ def _open_store(
7773 store_path , dimension_separator = dimension_separator
7874 )
7975 root = zarr .open_group (store , mode = mode , synchronizer = synchronizer )
76+ except zarr .errors .GroupNotFoundError as gnfe :
77+ try :
78+ root = zarr .open_group (store_path , mode = mode , synchronizer = synchronizer )
79+ except Exception as e2 :
80+ raise FileNotFoundError (
81+ f"Dataset directory not found at { store_path } ."
82+ ) from e2
8083 except Exception as e :
8184 raise RuntimeError (
8285 f"Cannot open Zarr root group at { store_path } "
@@ -332,20 +335,22 @@ def close(self):
332335class ImageArray (zarr .Array ):
333336 """Container object for image stored as a zarr array (up to 5D)"""
334337
335- def __init__ (self , zarray : zarr .Array ):
336- super ().__init__ (
337- store = zarray ._store ,
338- path = zarray ._path ,
339- read_only = zarray ._read_only ,
340- chunk_store = zarray ._chunk_store ,
341- synchronizer = zarray ._synchronizer ,
342- cache_metadata = zarray ._cache_metadata ,
343- cache_attrs = zarray ._attrs .cache ,
344- partial_decompress = zarray ._partial_decompress ,
345- write_empty_chunks = zarray ._write_empty_chunks ,
346- zarr_version = zarray ._version ,
347- meta_array = zarray ._meta_array ,
348- )
338+ def __init__ (self , zarray : zarr .Array = None , ** kwargs ):
339+ if zarray is not None :
340+ kwargs .update (
341+ store = zarray ._store ,
342+ path = zarray ._path ,
343+ read_only = zarray ._read_only ,
344+ chunk_store = zarray ._chunk_store ,
345+ synchronizer = zarray ._synchronizer ,
346+ cache_metadata = zarray ._cache_metadata ,
347+ cache_attrs = zarray ._attrs .cache ,
348+ partial_decompress = zarray ._partial_decompress ,
349+ write_empty_chunks = zarray ._write_empty_chunks ,
350+ zarr_version = zarray ._version ,
351+ meta_array = zarray ._meta_array ,
352+ )
353+ super ().__init__ (** kwargs )
349354 self ._get_dims ()
350355
351356 def _get_dims (self ):
@@ -1965,19 +1970,19 @@ def open_ome_zarr(
19651970 :py:class:`iohub.ngff.Plate`,
19661971 or :py:class:`iohub.ngff.TiledPosition`)
19671972 """
1968- store_path = Path (store_path )
1973+ local_store_path = Path (store_path )
19691974 if mode == "a" :
1970- mode = ("w-" , "r+" )[int (store_path .exists ())]
1975+ mode = ("w-" , "r+" )[int (local_store_path .exists ())]
19711976 parse_meta = False
19721977 if mode in ("r" , "r+" ):
19731978 parse_meta = True
19741979 elif mode == "w-" :
1975- if store_path .exists ():
1980+ if local_store_path .exists ():
19761981 raise FileExistsError (store_path )
19771982 elif mode == "w" :
1978- if store_path .exists ():
1983+ if local_store_path .exists ():
19791984 if (
1980- ".zarr" not in str (store_path .resolve ())
1985+ ".zarr" not in str (local_store_path .resolve ())
19811986 and not disable_path_checking
19821987 ):
19831988 raise ValueError (
0 commit comments