Skip to content

Commit

Permalink
complete test command
Browse files Browse the repository at this point in the history
  • Loading branch information
FynnBe committed Aug 5, 2024
1 parent dcfd021 commit 6a9bb2d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
10 changes: 5 additions & 5 deletions bioimageio/core/_resource_tests.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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]:
Expand Down Expand Up @@ -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})"
Expand Down Expand Up @@ -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)
Expand Down
15 changes: 14 additions & 1 deletion bioimageio/core/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Iterable,
List,
Mapping,
Optional,
Sequence,
Tuple,
Type,
Expand Down Expand Up @@ -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."""

Expand All @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions bioimageio/core/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down

0 comments on commit 6a9bb2d

Please sign in to comment.