Skip to content

Commit 05fa7d8

Browse files
committed
Rename open_backend_array as open_storage_array
Rename backend_storage_name as get_storage_name Rename is_backend_storage_array as is_storage_array cubed.storage.backend -> cubed.storage.store cubed.storage.backends -> cubed.storage.stores Update docs
1 parent c270021 commit 05fa7d8

File tree

18 files changed

+53
-57
lines changed

18 files changed

+53
-57
lines changed

cubed/core/ops.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from cubed.primitive.memory import get_buffer_copies
2424
from cubed.primitive.rechunk import rechunk as primitive_rechunk
2525
from cubed.spec import spec_from_config
26-
from cubed.storage.backend import is_backend_storage_array, open_backend_array
26+
from cubed.storage.store import is_storage_array, open_storage_array
2727
from cubed.storage.zarr import lazy_zarr_array
2828
from cubed.types import T_RegularChunks, T_Shape
2929
from cubed.utils import (
@@ -112,7 +112,7 @@ def from_zarr(store, path=None, spec=None) -> "Array":
112112
"""
113113
name = gensym()
114114
spec = spec or spec_from_config(config)
115-
target = open_backend_array(
115+
target = open_storage_array(
116116
store,
117117
mode="r",
118118
path=path,
@@ -181,7 +181,7 @@ def store(
181181

182182

183183
def _store_array(source: "Array", target, path=None, region=None):
184-
if target is not None and not is_backend_storage_array(target):
184+
if target is not None and not is_storage_array(target):
185185
target = lazy_zarr_array(
186186
target,
187187
shape=source.shape,

cubed/core/plan.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from cubed.primitive.types import PrimitiveOperation
1616
from cubed.runtime.pipeline import visit_nodes
1717
from cubed.runtime.types import ComputeEndEvent, ComputeStartEvent, CubedPipeline
18-
from cubed.storage.backend import is_backend_storage_array
18+
from cubed.storage.store import is_storage_array
1919
from cubed.storage.zarr import LazyZarrArray, open_if_lazy_zarr_array
2020
from cubed.utils import (
2121
chunk_memory,
@@ -456,9 +456,7 @@ def visualize(
456456
chunkmem = memory_repr(chunk_memory(target))
457457

458458
# materialized arrays are light orange, virtual arrays are white
459-
if isinstance(target, LazyZarrArray) or is_backend_storage_array(
460-
target
461-
):
459+
if isinstance(target, LazyZarrArray) or is_storage_array(target):
462460
d["style"] = "filled"
463461
d["fillcolor"] = "#ffd8b1"
464462
if n in array_display_names:

cubed/primitive/blockwise.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from cubed.primitive.memory import BufferCopies, MemoryModeller, calculate_projected_mem
1919
from cubed.primitive.types import CubedArrayProxy, PrimitiveOperation
2020
from cubed.runtime.types import CubedPipeline
21-
from cubed.storage.backend import is_backend_storage_array
21+
from cubed.storage.store import is_storage_array
2222
from cubed.storage.zarr import LazyZarrArray, T_ZarrArray, lazy_zarr_array
2323
from cubed.types import T_Chunks, T_DType, T_RegularChunks, T_Shape, T_Store
2424
from cubed.utils import (
@@ -367,9 +367,7 @@ def general_blockwise(
367367
f"All outputs must have matching number of blocks in each dimension. Chunks specified: {chunkss}"
368368
)
369369
ta: Union[zarr.Array, LazyZarrArray]
370-
if is_backend_storage_array(target_store) or isinstance(
371-
target_store, LazyZarrArray
372-
):
370+
if is_storage_array(target_store) or isinstance(target_store, LazyZarrArray):
373371
ta = target_store
374372
else:
375373
ta = lazy_zarr_array(

cubed/storage/backend.py renamed to cubed/storage/store.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from cubed.types import T_DType, T_RegularChunks, T_Shape, T_Store
55

66

7-
def backend_storage_name():
7+
def get_storage_name():
88
# get storage name from top-level config
99
# e.g. set globally with CUBED_STORAGE_NAME=tensorstore
1010
storage_name = config.get("storage_name", None)
@@ -20,23 +20,23 @@ def backend_storage_name():
2020
return storage_name
2121

2222

23-
def is_backend_storage_array(obj):
24-
storage_name = backend_storage_name()
23+
def is_storage_array(obj):
24+
storage_name = get_storage_name()
2525

2626
if storage_name == "zarr-python":
2727
import zarr
2828

29-
from cubed.storage.backends.zarr_python import ZarrArrayGroup
29+
from cubed.storage.stores.zarr_python import ZarrArrayGroup
3030

3131
return isinstance(obj, (zarr.Array, ZarrArrayGroup))
3232
elif storage_name in ("zarr-python-v3", "zarrs-python"):
3333
import zarr
3434

35-
from cubed.storage.backends.zarr_python_v3 import ZarrV3ArrayGroup
35+
from cubed.storage.stores.zarr_python_v3 import ZarrV3ArrayGroup
3636

3737
return isinstance(obj, (zarr.Array, ZarrV3ArrayGroup))
3838
elif storage_name == "tensorstore":
39-
from cubed.storage.backends.tensorstore import (
39+
from cubed.storage.stores.tensorstore import (
4040
TensorStoreArray,
4141
TensorStoreGroup,
4242
)
@@ -46,7 +46,7 @@ def is_backend_storage_array(obj):
4646
raise ValueError(f"Unrecognized storage name: {storage_name}")
4747

4848

49-
def open_backend_array(
49+
def open_storage_array(
5050
store: T_Store,
5151
mode: str,
5252
*,
@@ -56,10 +56,10 @@ def open_backend_array(
5656
path: Optional[str] = None,
5757
**kwargs,
5858
):
59-
storage_name = backend_storage_name()
59+
storage_name = get_storage_name()
6060

6161
if storage_name == "zarr-python":
62-
from cubed.storage.backends.zarr_python import open_zarr_array # type: ignore
62+
from cubed.storage.stores.zarr_python import open_zarr_array # type: ignore
6363

6464
open_func = open_zarr_array
6565

@@ -73,15 +73,15 @@ def open_backend_array(
7373
kwargs["object_codec"] = object_codec
7474

7575
elif storage_name == "zarr-python-v3":
76-
from cubed.storage.backends.zarr_python_v3 import open_zarr_v3_array
76+
from cubed.storage.stores.zarr_python_v3 import open_zarr_v3_array
7777

7878
open_func = open_zarr_v3_array
7979
elif storage_name == "zarrs-python":
80-
from cubed.storage.backends.zarrs_python import open_zarr_v3_array
80+
from cubed.storage.stores.zarrs_python import open_zarr_v3_array
8181

8282
open_func = open_zarr_v3_array
8383
elif storage_name == "tensorstore":
84-
from cubed.storage.backends.tensorstore import open_tensorstore_array
84+
from cubed.storage.stores.tensorstore import open_tensorstore_array
8585

8686
open_func = open_tensorstore_array
8787
else:
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

cubed/storage/backends/zarrs_python.py renamed to cubed/storage/stores/zarrs_python.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import zarrs # noqa: F401
33

44
# re-export the Zarr v3 open function
5-
from cubed.storage.backends.zarr_python_v3 import open_zarr_v3_array # noqa: F401
5+
from cubed.storage.stores.zarr_python_v3 import open_zarr_v3_array # noqa: F401
66

77
# need to set zarr config after importing from zarr_python_v3 to ensure pipeline is set
88
zarr.config.set(

cubed/storage/zarr.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import zarr
44

5-
from cubed.storage.backend import open_backend_array
5+
from cubed.storage.store import open_storage_array
66
from cubed.storage.types import ArrayMetadata
77
from cubed.types import T_DType, T_RegularChunks, T_Shape, T_Store
88

@@ -42,7 +42,7 @@ def create(self, mode: str = "w-") -> zarr.Array:
4242
The mode to open the Zarr array with using ``zarr.open``.
4343
Default is 'w-', which means create, fail it already exists.
4444
"""
45-
target = open_backend_array(
45+
target = open_storage_array(
4646
self.store,
4747
mode=mode,
4848
shape=self.shape,
@@ -59,7 +59,7 @@ def open(self) -> zarr.Array:
5959
Note that the Zarr array must have been created or this method will raise an exception.
6060
"""
6161
# r+ means read/write, fail if it doesn't exist
62-
return open_backend_array(
62+
return open_storage_array(
6363
self.store,
6464
mode="r+",
6565
shape=self.shape,

0 commit comments

Comments
 (0)