@@ -139,6 +139,16 @@ def _normalize_store_arg_v2(store: Any, storage_options=None, mode="r") -> BaseS
139
139
return store
140
140
if isinstance (store , os .PathLike ):
141
141
store = os .fspath (store )
142
+ if FSStore ._fsspec_installed ():
143
+ import fsspec
144
+ if isinstance (store , fsspec .FSMap ):
145
+ return FSStore (store .root ,
146
+ fs = store .fs ,
147
+ mode = mode ,
148
+ check = store .check ,
149
+ create = store .create ,
150
+ missing_exceptions = store .missing_exceptions ,
151
+ ** (storage_options or {}))
142
152
if isinstance (store , str ):
143
153
if "://" in store or "::" in store :
144
154
return FSStore (store , mode = mode , ** (storage_options or {}))
@@ -1308,6 +1318,8 @@ def __init__(self, url, normalize_keys=False, key_separator=None,
1308
1318
create = False ,
1309
1319
missing_exceptions = None ,
1310
1320
** storage_options ):
1321
+ if not self ._fsspec_installed (): # pragma: no cover
1322
+ raise ImportError ("`fsspec` is required to use zarr's FSStore" )
1311
1323
import fsspec
1312
1324
1313
1325
mapper_options = {"check" : check , "create" : create }
@@ -1479,6 +1491,13 @@ def clear(self):
1479
1491
raise ReadOnlyError ()
1480
1492
self .map .clear ()
1481
1493
1494
+ @classmethod
1495
+ def _fsspec_installed (cls ):
1496
+ """Returns true if fsspec is installed"""
1497
+ import importlib .util
1498
+
1499
+ return importlib .util .find_spec ("fsspec" ) is not None
1500
+
1482
1501
1483
1502
class TempStore (DirectoryStore ):
1484
1503
"""Directory store using a temporary directory for storage.
0 commit comments