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
23 changes: 20 additions & 3 deletions tests/test_io.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import sys
from importlib.util import find_spec
from inspect import signature
from pathlib import Path
from typing import Literal

Expand Down Expand Up @@ -69,6 +71,9 @@ def test_save_sample(tmp_path: Path, suffix: str):
from bioimageio.core.common import MemberId
from bioimageio.core.io import load_tensor, save_sample

if suffix == ".zarr" and find_spec("clearscale") is None:
pytest.importorskip("bioio_ome_zarr")

members = {
MemberId("raw"): np.arange(30, dtype=np.uint8).reshape(5, 6),
MemberId("mask"): np.ones((5, 6), dtype=np.uint8),
Expand Down Expand Up @@ -135,6 +140,10 @@ def test_tensor_io(

if name.find(".zarr") == -1:
pytest.skip("clearscale only supports zarr")
elif io_lib == "bioio" and (
name.endswith(".zarr") or name.endswith(".zarr/0")
):
pytest.importorskip("bioio_ome_zarr")
elif io_lib == "imageio":
if name.find(".zarr") != -1:
pytest.skip("imageio does not support zarr")
Expand Down Expand Up @@ -225,6 +234,8 @@ def test_load_zarr_from_group(
):
if io_lib == "clearscale":
_ = pytest.importorskip("clearscale")
else:
pytest.importorskip("bioio_ome_zarr")

import zarr

Expand All @@ -233,10 +244,16 @@ def test_load_zarr_from_group(
default_scale_key = "0"
storage_source = tmp_path / "image.ome.zarr"
group_source = storage_source / group_path if storage_source else storage_source
group = zarr.open_group(group_source, mode="w", zarr_format=2)
uses_zarr_format = "zarr_format" in signature(zarr.open_group).parameters
if uses_zarr_format:
group = zarr.open_group(group_source, mode="w", zarr_format=2)
else:
group = zarr.open_group(group_source, mode="w")
expected = np.arange(2 * 3 * 4 * 5, dtype=np.uint16).reshape(2, 3, 4, 5)
_ = group.create_array(scale_key or default_scale_key, data=expected)
# group = zarr.open_group(storage_source, mode="a", zarr_format=2)
if uses_zarr_format:
_ = group.create_array(scale_key or default_scale_key, data=expected)
else:
_ = group.create_dataset(scale_key or default_scale_key, data=expected)
group.attrs["multiscales"] = [
{
"version": "0.4",
Expand Down
6 changes: 4 additions & 2 deletions tests/test_resource_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,12 @@ def test_loading_description_multiple_times(unet2d_nuclei_broad_model: str):
assert not isinstance(model_descr, InvalidDescr)


def test_test_description_runtime_env(unet2d_nuclei_broad_model: str):
def test_test_description_runtime_env(unet2d_nuclei_broad_model_old: str):
from bioimageio.core._resource_tests import test_description

summary = test_description(unet2d_nuclei_broad_model, runtime_env="as-described")
summary = test_description(
unet2d_nuclei_broad_model_old, runtime_env="as-described"
)

assert summary.status == "passed", summary.display()

Expand Down
Loading