Skip to content

Commit 6a9bb2d

Browse files
committed
complete test command
1 parent dcfd021 commit 6a9bb2d

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed

bioimageio/core/_resource_tests.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import traceback
22
import warnings
33
from itertools import product
4-
from typing import Dict, Hashable, List, Literal, Optional, Set, Tuple, Union
4+
from typing import Dict, Hashable, List, Literal, Optional, Sequence, Set, Tuple, Union
55

66
import numpy as np
77
from loguru import logger
@@ -52,7 +52,7 @@ def test_description(
5252
*,
5353
format_version: Union[Literal["discover", "latest"], str] = "discover",
5454
weight_format: Optional[WeightsFormat] = None,
55-
devices: Optional[List[str]] = None,
55+
devices: Optional[Sequence[str]] = None,
5656
decimal: int = 4,
5757
expected_type: Optional[str] = None,
5858
) -> ValidationSummary:
@@ -73,7 +73,7 @@ def load_description_and_test(
7373
*,
7474
format_version: Union[Literal["discover", "latest"], str] = "discover",
7575
weight_format: Optional[WeightsFormat] = None,
76-
devices: Optional[List[str]] = None,
76+
devices: Optional[Sequence[str]] = None,
7777
decimal: int = 4,
7878
expected_type: Optional[str] = None,
7979
) -> Union[ResourceDescr, InvalidDescr]:
@@ -123,7 +123,7 @@ def load_description_and_test(
123123
def _test_model_inference(
124124
model: Union[v0_4.ModelDescr, v0_5.ModelDescr],
125125
weight_format: WeightsFormat,
126-
devices: Optional[List[str]],
126+
devices: Optional[Sequence[str]],
127127
decimal: int,
128128
) -> None:
129129
test_name = f"Reproduce test outputs from test inputs ({weight_format})"
@@ -182,7 +182,7 @@ def _test_model_inference(
182182
def _test_model_inference_parametrized(
183183
model: v0_5.ModelDescr,
184184
weight_format: WeightsFormat,
185-
devices: Optional[List[str]],
185+
devices: Optional[Sequence[str]],
186186
) -> None:
187187
if not any(
188188
isinstance(a.size, v0_5.ParameterizedSize)

bioimageio/core/cli.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
Iterable,
66
List,
77
Mapping,
8+
Optional,
89
Sequence,
910
Tuple,
1011
Type,
@@ -89,6 +90,7 @@ def descr_id(self) -> str:
8990
)
9091

9192

93+
9294
class ValidateFormatCmd(CmdBase, WithSource):
9395
"""bioimageio-validate-format - validate the meta data format of a bioimageio resource."""
9496

@@ -99,8 +101,19 @@ def run(self):
99101
class TestCmd(CmdBase, WithSource):
100102
"""bioimageio-test - Test a bioimageio resource (beyond meta data formatting)"""
101103

104+
weight_format: WeightFormatArg = "all"
105+
"""The weight format to limit testing to.
106+
107+
(only relevant for model resources)"""
108+
109+
devices: Optional[Union[str, Sequence[str]]] = None
110+
"""Device(s) to use for testing"""
111+
112+
decimal: int = 4
113+
"""Precision for numerical comparisons"""
114+
102115
def run(self):
103-
test(self.descr)
116+
test(self.descr, weight_format=self.weight_format, devices=self.devices,decimal= self.decimal)
104117

105118

106119
class PackageCmd(CmdBase, WithSource):

bioimageio/core/commands.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import sys
55
from pathlib import Path
6-
from typing import List, Optional, Union
6+
from typing import List, Optional, Sequence, Union
77

88
from typing_extensions import Literal
99

@@ -23,7 +23,7 @@ def test(
2323
descr: Union[ResourceDescr, InvalidDescr],
2424
*,
2525
weight_format: WeightFormatArg = "all",
26-
devices: Optional[Union[str, List[str]]] = None,
26+
devices: Optional[Union[str, Sequence[str]]] = None,
2727
decimal: int = 4,
2828
):
2929
"""test a bioimageio resource

0 commit comments

Comments
 (0)