-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make it possible to configure alternative storage backends. This will…
… make it easier to work with Zarr v3. (#480)
- Loading branch information
Showing
9 changed files
with
87 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from typing import Optional | ||
|
||
from cubed import config | ||
from cubed.types import T_DType, T_RegularChunks, T_Shape, T_Store | ||
|
||
|
||
def open_backend_array( | ||
store: T_Store, | ||
mode: str, | ||
*, | ||
shape: Optional[T_Shape] = None, | ||
dtype: Optional[T_DType] = None, | ||
chunks: Optional[T_RegularChunks] = None, | ||
path: Optional[str] = None, | ||
**kwargs, | ||
): | ||
# get storage name from top-level config | ||
# e.g. set globally with CUBED_STORAGE_NAME=tensorstore | ||
storage_name = config.get("storage_name", None) | ||
|
||
if storage_name is None or storage_name == "zarr-python": | ||
from cubed.storage.backends.zarr_python import open_zarr_array | ||
|
||
open_func = open_zarr_array | ||
else: | ||
raise ValueError(f"Unrecognized storage name: {storage_name}") | ||
|
||
return open_func( | ||
store, | ||
mode, | ||
shape=shape, | ||
dtype=dtype, | ||
chunks=chunks, | ||
path=path, | ||
**kwargs, | ||
) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from typing import Optional | ||
|
||
import zarr | ||
|
||
from cubed.types import T_DType, T_RegularChunks, T_Shape, T_Store | ||
|
||
|
||
def open_zarr_array( | ||
store: T_Store, | ||
mode: str, | ||
*, | ||
shape: Optional[T_Shape] = None, | ||
dtype: Optional[T_DType] = None, | ||
chunks: Optional[T_RegularChunks] = None, | ||
path: Optional[str] = None, | ||
**kwargs, | ||
): | ||
return zarr.open_array( | ||
store, | ||
mode=mode, | ||
shape=shape, | ||
dtype=dtype, | ||
chunks=chunks, | ||
path=path, | ||
**kwargs, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters