Skip to content

Commit

Permalink
Add Zarr V3 tests. Add a note about environment variables in Zarr V3 …
Browse files Browse the repository at this point in the history
…tests.
  • Loading branch information
aliddell committed Nov 17, 2023
1 parent 0f40e26 commit 7ccb9c3
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ jobs:
permissions:
actions: write

env:
ZARR_V3_EXPERIMENTAL_API: 1
ZARR_V3_SHARDING: 1

steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/test_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ jobs:
actions: write
env:
GH_TOKEN: ${{ github.token }}
ZARR_V3_EXPERIMENTAL_API: 1
ZARR_V3_SHARDING: 1
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,13 @@ It depends on what you changed:
- **acquire-video-runtime** (c/c++ code): `touch wrapper.h; maturin develop`
- **rust code**: `maturin develop`

### Zarr V3 tests are failing

You should make sure that the following environment variables are set:

```
ZARR_V3_EXPERIMENTAL_API: 1
ZARR_V3_SHARDING: 1
```

[napari]: https://github.com/napari/napari
57 changes: 57 additions & 0 deletions tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,63 @@ def test_write_zarr_multiscale(
image = downscale_local_mean(image, (2, 2)).astype(np.uint8)


@pytest.mark.parametrize(
("number_of_frames", "expected_number_of_chunks", "codec"),
[
(64, 4, None),
(64, 4, "zstd"),
(65, 8, None), # rollover
(65, 8, "lz4"), # rollover
],
)
def test_write_zarr_v3(
runtime: acquire.Runtime,
request: pytest.FixtureRequest,
number_of_frames: int,
expected_number_of_chunks: int,
codec: Optional[str],
):
dm = runtime.device_manager()

p = runtime.get_configuration()
p.video[0].camera.identifier = dm.select(
DeviceKind.Camera, "simulated.*empty.*"
)

p.video[0].camera.settings.shape = (1920, 1080)
p.video[0].camera.settings.exposure_time_us = 1e4
p.video[0].camera.settings.pixel_type = acquire.SampleType.U8
p.video[0].storage.identifier = dm.select(
DeviceKind.Storage,
f"ZarrV3Blosc1{codec.capitalize()}ByteShuffle" if codec else "ZarrV3",
)
p.video[0].storage.settings.filename = f"{request.node.name}.zarr"
p.video[0].max_frame_count = number_of_frames

p.video[0].storage.settings.chunk_dims_px.width = 1920 // 2
p.video[0].storage.settings.chunk_dims_px.height = 1080 // 2
p.video[0].storage.settings.chunk_dims_px.planes = 64

runtime.set_configuration(p)

runtime.start()
runtime.stop()

store = zarr.DirectoryStoreV3(p.video[0].storage.settings.filename)
group = zarr.open(store=store, mode="r")
data = group["0"]

assert data.chunks == (64, 1, 1080 // 2, 1920 // 2)

assert data.shape == (
number_of_frames,
1,
p.video[0].camera.settings.shape[1],
p.video[0].camera.settings.shape[0],
)
assert data.nchunks == expected_number_of_chunks


@pytest.mark.skip(
reason="Runs into memory limitations on github ci."
+ " See https://github.com/acquire-project/cpx/issues/147"
Expand Down

0 comments on commit 7ccb9c3

Please sign in to comment.