diff --git a/bioimageio/core/_resource_tests.py b/bioimageio/core/_resource_tests.py index 4488cb56..40ff78b0 100644 --- a/bioimageio/core/_resource_tests.py +++ b/bioimageio/core/_resource_tests.py @@ -1,7 +1,7 @@ import traceback import warnings from itertools import product -from typing import Dict, Hashable, List, Literal, Optional, Set, Tuple, Union +from typing import Dict, Hashable, List, Literal, Optional, Sequence, Set, Tuple, Union import numpy as np from loguru import logger @@ -52,7 +52,7 @@ def test_description( *, format_version: Union[Literal["discover", "latest"], str] = "discover", weight_format: Optional[WeightsFormat] = None, - devices: Optional[List[str]] = None, + devices: Optional[Sequence[str]] = None, decimal: int = 4, expected_type: Optional[str] = None, ) -> ValidationSummary: @@ -73,7 +73,7 @@ def load_description_and_test( *, format_version: Union[Literal["discover", "latest"], str] = "discover", weight_format: Optional[WeightsFormat] = None, - devices: Optional[List[str]] = None, + devices: Optional[Sequence[str]] = None, decimal: int = 4, expected_type: Optional[str] = None, ) -> Union[ResourceDescr, InvalidDescr]: @@ -123,7 +123,7 @@ def load_description_and_test( def _test_model_inference( model: Union[v0_4.ModelDescr, v0_5.ModelDescr], weight_format: WeightsFormat, - devices: Optional[List[str]], + devices: Optional[Sequence[str]], decimal: int, ) -> None: test_name = f"Reproduce test outputs from test inputs ({weight_format})" @@ -182,7 +182,7 @@ def _test_model_inference( def _test_model_inference_parametrized( model: v0_5.ModelDescr, weight_format: WeightsFormat, - devices: Optional[List[str]], + devices: Optional[Sequence[str]], ) -> None: if not any( isinstance(a.size, v0_5.ParameterizedSize) diff --git a/bioimageio/core/cli.py b/bioimageio/core/cli.py index 0aab4e3c..aa430910 100644 --- a/bioimageio/core/cli.py +++ b/bioimageio/core/cli.py @@ -5,6 +5,7 @@ Iterable, List, Mapping, + Optional, Sequence, Tuple, Type, @@ -89,6 +90,7 @@ def descr_id(self) -> str: ) + class ValidateFormatCmd(CmdBase, WithSource): """bioimageio-validate-format - validate the meta data format of a bioimageio resource.""" @@ -99,8 +101,19 @@ def run(self): class TestCmd(CmdBase, WithSource): """bioimageio-test - Test a bioimageio resource (beyond meta data formatting)""" + weight_format: WeightFormatArg = "all" + """The weight format to limit testing to. + + (only relevant for model resources)""" + + devices: Optional[Union[str, Sequence[str]]] = None + """Device(s) to use for testing""" + + decimal: int = 4 + """Precision for numerical comparisons""" + def run(self): - test(self.descr) + test(self.descr, weight_format=self.weight_format, devices=self.devices,decimal= self.decimal) class PackageCmd(CmdBase, WithSource): diff --git a/bioimageio/core/commands.py b/bioimageio/core/commands.py index 9a2ddb18..684d08ad 100644 --- a/bioimageio/core/commands.py +++ b/bioimageio/core/commands.py @@ -3,7 +3,7 @@ import sys from pathlib import Path -from typing import List, Optional, Union +from typing import List, Optional, Sequence, Union from typing_extensions import Literal @@ -23,7 +23,7 @@ def test( descr: Union[ResourceDescr, InvalidDescr], *, weight_format: WeightFormatArg = "all", - devices: Optional[Union[str, List[str]]] = None, + devices: Optional[Union[str, Sequence[str]]] = None, decimal: int = 4, ): """test a bioimageio resource