Skip to content

Commit 6a3faeb

Browse files
authored
Add support for zarrs-python (#789)
* Add support for zarrs-python * Fix mypy
1 parent 149c3e7 commit 6a3faeb

File tree

4 files changed

+66
-0
lines changed

4 files changed

+66
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Zarrs-python tests
2+
3+
on:
4+
pull_request:
5+
schedule:
6+
# Every weekday at 03:43 UTC, see https://crontab.guru/
7+
- cron: "43 3 * * 1-5"
8+
workflow_dispatch:
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
test:
16+
runs-on: ${{ matrix.os }}
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
os: ["ubuntu-latest"]
21+
python-version: ["3.12"]
22+
23+
steps:
24+
- name: Checkout source
25+
uses: actions/checkout@v3
26+
with:
27+
fetch-depth: 0
28+
29+
- name: Set up Python
30+
uses: actions/setup-python@v3
31+
with:
32+
python-version: ${{ matrix.python-version }}
33+
architecture: x64
34+
35+
- name: Setup Graphviz
36+
uses: ts-graphviz/setup-graphviz@v2
37+
38+
- name: Install
39+
run: |
40+
python -m pip install --upgrade pip
41+
python -m pip install -e '.[test]' 'zarrs'
42+
43+
- name: Run tests
44+
run: |
45+
pytest -v
46+
env:
47+
CUBED_STORAGE_NAME: zarrs-python

cubed/storage/backend.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ def open_backend_array(
4949
elif storage_name == "zarr-python-v3":
5050
from cubed.storage.backends.zarr_python_v3 import open_zarr_v3_array
5151

52+
open_func = open_zarr_v3_array
53+
elif storage_name == "zarrs-python":
54+
from cubed.storage.backends.zarrs_python import open_zarr_v3_array
55+
5256
open_func = open_zarr_v3_array
5357
elif storage_name == "tensorstore":
5458
from cubed.storage.backends.tensorstore import open_tensorstore_array
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import zarr
2+
import zarrs # noqa: F401
3+
4+
# re-export the Zarr v3 open function
5+
from cubed.storage.backends.zarr_python_v3 import open_zarr_v3_array # noqa: F401
6+
7+
# need to set zarr config after importing from zarr_python_v3 to ensure pipeline is set
8+
zarr.config.set(
9+
{
10+
"array.write_empty_chunks": True,
11+
"codec_pipeline.path": "zarrs.ZarrsCodecPipeline",
12+
}
13+
)

setup.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,7 @@ ignore_missing_imports = True
7777
ignore_missing_imports = True
7878
[mypy-zarr.*]
7979
ignore_missing_imports = True
80+
[mypy-zarrs.*]
81+
ignore_missing_imports = True
8082
[mypy-pyspark.*]
8183
ignore_missing_imports = True

0 commit comments

Comments
 (0)