File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ from pathlib import Path
12from typing import Optional
23
34import zarr
@@ -39,6 +40,22 @@ def open_zarr_v3_array(
3940 path : Optional [str ] = None ,
4041 ** kwargs ,
4142):
43+ # use obstore if requested
44+ storage_options = kwargs .get ("storage_options" , None )
45+ if storage_options is not None and storage_options .get ("use_obstore" , False ):
46+ import obstore as obs
47+ from zarr .storage import ObjectStore
48+
49+ if isinstance (store , str ):
50+ if "://" not in store :
51+ p = Path (store )
52+ store = ObjectStore (obs .store .from_url (p .as_uri (), mkdir = True ))
53+ else :
54+ store = ObjectStore (obs .store .from_url (store ))
55+ elif isinstance (store , Path ):
56+ p = store
57+ store = ObjectStore (obs .store .from_url (p .as_uri (), mkdir = True ))
58+
4259 if isinstance (chunks , int ):
4360 chunks = (chunks ,)
4461
Original file line number Diff line number Diff line change @@ -47,6 +47,8 @@ ignore_missing_imports = True
4747ignore_missing_imports = True
4848[mypy-numpy.*]
4949ignore_missing_imports = True
50+ [mypy-obstore.*]
51+ ignore_missing_imports = True
5052[mypy-pandas.*]
5153ignore_missing_imports = True
5254[mypy-psutil.*]
You can’t perform that action at this time.
0 commit comments