Skip to content

Commit 0ebcfd3

Browse files
committed
update tests
1 parent 57ea3ff commit 0ebcfd3

File tree

1 file changed

+83
-39
lines changed

1 file changed

+83
-39
lines changed

tests/test_bioimageio_collection.py

Lines changed: 83 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
2-
from typing import Any, Collection, Dict, Iterable, Mapping, Tuple
2+
from itertools import chain
3+
from typing import Any, Dict, Iterable, Mapping, Tuple
34

45
import httpx
56
import pytest
@@ -39,39 +40,44 @@ def yield_bioimageio_yaml_urls() -> Iterable[ParameterSet]:
3940
yield pytest.param(descr_url, sha, key, id=key)
4041

4142

42-
KNOWN_INVALID: Collection[str] = {
43-
"affectionate-cow/0.1.0", # custom dependencies
44-
"ambitious-sloth/1.2", # requires inferno
45-
"committed-turkey/1.2", # error deserializing VarianceScaling
46-
"creative-panda/1", # error deserializing Conv2D
47-
"dazzling-spider/0.1.0", # requires careamics
48-
"discreet-rooster/1", # error deserializing VarianceScaling
49-
"discreete-rooster/1", # error deserializing VarianceScaling
50-
"dynamic-t-rex/1", # needs update to 0.5 for scale_linear with axes processing
51-
"easy-going-sauropod/1", # CPU implementation of Conv3D currently only supports the NHWC tensor format.
52-
"efficient-chipmunk/1", # needs plantseg
53-
"emotional-cricket/1.1", # sporadic 403 responses from https://elifesciences.org
54-
"famous-fish/0.1.0", # list index out of range `fl[3]`
55-
"greedy-whale/1", # batch size is actually limited to 1
56-
"happy-elephant/0.1.0", # list index out of range `fl[3]`
57-
"happy-honeybee/0.1.0", # requires biapy
58-
"heroic-otter/0.1.0", # requires biapy
59-
"humorous-crab/1", # batch size is actually limited to 1
60-
"humorous-fox/0.1.0", # requires careamics
61-
"humorous-owl/1", # error deserializing GlorotUniform
62-
"idealistic-turtle/0.1.0", # requires biapy
63-
"impartial-shark/1", # error deserializing VarianceScaling
64-
"intelligent-lion/0.1.0", # requires biapy
65-
"joyful-deer/1", # needs update to 0.5 for scale_linear with axes processing
66-
"merry-water-buffalo/0.1.0", # requires biapy
67-
"naked-microbe/1", # unknown layer Convolution2D
68-
"noisy-ox/1", # batch size is actually limited to 1
69-
"non-judgemental-eagle/1", # error deserializing GlorotUniform
70-
"straightforward-crocodile/1", # needs update to 0.5 for scale_linear with axes processing
71-
"stupendous-sheep/1.1", # requires relativ import of attachment
72-
"stupendous-sheep/1.2",
73-
"venomous-swan/0.1.0", # requires biapy
74-
"wild-rhino/0.1.0", # requires careamics
43+
KNOWN_INVALID: Mapping[str, str] = {
44+
"affectionate-cow/0.1.0": "custom dependencies",
45+
"ambitious-sloth/1.2": "requires inferno",
46+
"committed-turkey/1.2": "error deserializing VarianceScaling",
47+
"creative-panda/1": "error deserializing Conv2D",
48+
"dazzling-spider/0.1.0": "requires careamics",
49+
"discreet-rooster/1": "error deserializing VarianceScaling",
50+
"discreete-rooster/1": "error deserializing VarianceScaling",
51+
"dynamic-t-rex/1": "needs update to 0.5 for scale_linear with axes processing",
52+
"easy-going-sauropod/1": (
53+
"CPU implementation of Conv3D currently only supports the NHWC tensor format."
54+
),
55+
"efficient-chipmunk/1": "needs plantseg",
56+
"emotional-cricket/1.1": "sporadic 403 responses from https://elifesciences.org",
57+
"famous-fish/0.1.0": "list index out of range `fl[3]`",
58+
"greedy-whale/1": "batch size is actually limited to 1",
59+
"happy-elephant/0.1.0": "list index out of range `fl[3]`",
60+
"happy-honeybee/0.1.0": "requires biapy",
61+
"heroic-otter/0.1.0": "requires biapy",
62+
"humorous-crab/1": "batch size is actually limited to 1",
63+
"humorous-fox/0.1.0": "requires careamics",
64+
"humorous-owl/1": "error deserializing GlorotUniform",
65+
"idealistic-turtle/0.1.0": "requires biapy",
66+
"impartial-shark/1": "error deserializing VarianceScaling",
67+
"intelligent-lion/0.1.0": "requires biapy",
68+
"joyful-deer/1": "needs update to 0.5 for scale_linear with axes processing",
69+
"merry-water-buffalo/0.1.0": "requires biapy",
70+
"naked-microbe/1": "unknown layer Convolution2D",
71+
"noisy-ox/1": "batch size is actually limited to 1",
72+
"non-judgemental-eagle/1": "error deserializing GlorotUniform",
73+
"straightforward-crocodile/1": (
74+
"needs update to 0.5 for scale_linear with axes processing"
75+
),
76+
"stupendous-sheep/1.1": "requires relativ import of attachment",
77+
"venomous-swan/0.1.0": "requires biapy",
78+
"whimsical-helmet/2.1.2": "invalid id",
79+
"wild-rhino/0.1.0": "requires careamics",
80+
"zero/notebook_preview/1": "missing authors",
7581
}
7682

7783

@@ -83,10 +89,10 @@ def test_rdf_format_to_populate_cache(
8389
):
8490
"""this test is redundant if `test_rdf` runs, but is used in the CI to populate the cache"""
8591
if os.environ.get("BIOIMAGEIO_POPULATE_CACHE") != "1":
86-
pytest.skip("only runs in CI to populate cache")
92+
pytest.skip("BIOIMAGEIO_POPULATE_CACHE != 1")
8793

8894
if key in KNOWN_INVALID:
89-
pytest.skip("known failure")
95+
pytest.skip(KNOWN_INVALID[key])
9096

9197
from bioimageio.core import load_description
9298

@@ -100,12 +106,50 @@ def test_rdf(
100106
sha: Sha256,
101107
key: str,
102108
):
109+
from bioimageio.spec import get_conda_env
110+
from bioimageio.spec.model import ModelDescr
111+
103112
if key in KNOWN_INVALID:
104-
pytest.skip("known failure")
113+
pytest.skip(KNOWN_INVALID[key])
114+
115+
from bioimageio.core import load_description, load_description_and_test
105116

106-
from bioimageio.core import load_description_and_test
117+
descr = load_description(
118+
descr_url, sha256=sha, format_version="latest", perform_io_checks=True
119+
)
120+
assert not isinstance(descr, InvalidDescr), descr.validation_summary.display()
107121

108-
descr = load_description_and_test(descr_url, sha256=sha, stop_early=True)
122+
if (
123+
isinstance(descr, ModelDescr)
124+
and descr.weights.pytorch_state_dict is not None
125+
and descr.weights.pytorch_state_dict.dependencies is not None
126+
):
127+
conda_env = get_conda_env(entry=descr.weights.pytorch_state_dict)
128+
129+
def depends_on(dep: str) -> bool:
130+
return any(
131+
chain(
132+
(d.startswith(dep) for d in conda_env.get_pip_deps()),
133+
(cd for cd in conda_env.dependencies if isinstance(cd, str)),
134+
)
135+
)
136+
137+
for skip_if_depends_on in (
138+
"biapy",
139+
"git+https://github.com/CAREamics/careamics.git",
140+
"careamics",
141+
"inferno",
142+
"plantseg",
143+
):
144+
if depends_on(skip_if_depends_on):
145+
pytest.skip(f"requires {skip_if_depends_on}")
146+
147+
descr = load_description_and_test(
148+
descr,
149+
format_version="latest",
150+
sha256=sha,
151+
stop_early=True,
152+
)
109153

110154
assert not isinstance(descr, InvalidDescr), descr.validation_summary.display()
111155
assert (

0 commit comments

Comments
 (0)