Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions cubed/storage/backends/zarr_python_v3.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from pathlib import Path
from typing import Optional

import zarr
Expand Down Expand Up @@ -39,6 +40,22 @@ def open_zarr_v3_array(
path: Optional[str] = None,
**kwargs,
):
# use obstore if requested
storage_options = kwargs.get("storage_options", None)
if storage_options is not None and storage_options.get("use_obstore", False):
import obstore as obs
from zarr.storage import ObjectStore

if isinstance(store, str):
if "://" not in store:
p = Path(store)
store = ObjectStore(obs.store.from_url(p.as_uri(), mkdir=True))
else:
store = ObjectStore(obs.store.from_url(store))
elif isinstance(store, Path):
p = store
store = ObjectStore(obs.store.from_url(p.as_uri(), mkdir=True))

if isinstance(chunks, int):
chunks = (chunks,)

Expand Down
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ ignore_missing_imports = True
ignore_missing_imports = True
[mypy-numpy.*]
ignore_missing_imports = True
[mypy-obstore.*]
ignore_missing_imports = True
[mypy-pandas.*]
ignore_missing_imports = True
[mypy-psutil.*]
Expand Down