diff --git a/.vscode/settings.json b/.vscode/settings.json index 64b5cecc..818f0bac 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -12,4 +12,11 @@ ], "python.testing.pytestEnabled": true, "python.testing.unittestEnabled": false, + "python-envs.pythonProjects": [ + { + "path": "", + "envManager": "ms-python.python:conda", + "packageManager": "ms-python.python:conda" + } + ], } diff --git a/README.md b/README.md index e45cf5a7..91a0fe0b 100644 --- a/README.md +++ b/README.md @@ -364,6 +364,15 @@ may be controlled with the `LOGURU_LEVEL` environment variable. ## Changelog +### next release + +- fixes: + - CLI + - improved handling of summary argument to not create a path with brackets when given a list of paths. + - improved backward compatibility when runnig tests for models specifying an older bioimageio.core version in their environment. + This is relevant when using `runtime_env="as-described"`. + It works by simply trying option `--summary` (new option name) and `--summary-path` (outdated option name). + ### 0.9.0 - update to [bioimageio.spec 0.5.4.3](https://github.com/bioimage-io/spec-bioimage-io/blob/main/changelog.md#bioimageiospec-0543) diff --git a/bioimageio/core/_resource_tests.py b/bioimageio/core/_resource_tests.py index 67843d7e..690ea918 100644 --- a/bioimageio/core/_resource_tests.py +++ b/bioimageio/core/_resource_tests.py @@ -404,21 +404,50 @@ def _test_in_env( ) return summary - run_command( - [ - "conda", - "run", - "-n", - env_name, - "bioimageio", - "test", - str(source), - f"--summary-path={summary_path}", - f"--determinism={determinism}", - ] - + ([f"--expected-type={expected_type}"] if expected_type else []) - + (["--stop-early"] if stop_early else []) - ) + cmd = [] + for summary_path_arg_name in ("summary", "summary-path"): + run_command( + cmd := ( + [ + "conda", + "run", + "-n", + env_name, + "bioimageio", + "test", + str(source), + f"--{summary_path_arg_name}={summary_path.as_posix()}", + f"--determinism={determinism}", + ] + + ([f"--expected-type={expected_type}"] if expected_type else []) + + (["--stop-early"] if stop_early else []) + ) + ) + if summary_path.exists(): + break + else: + return ValidationSummary( + name="calling bioimageio test command", + source_name=str(source), + status="failed", + type="unknown", + format_version="unknown", + details=[ + ValidationDetail( + name="run 'bioimageio test'", + errors=[ + ErrorEntry( + loc=(), + type="bioimageio cli", + msg=f"test command '{' '.join(cmd)}' did not produce a summary file at {summary_path}", + ) + ], + status="failed", + ) + ], + env=set(), + ) + return ValidationSummary.model_validate_json(summary_path.read_bytes()) diff --git a/bioimageio/core/cli.py b/bioimageio/core/cli.py index 9be8f2a6..d5c49067 100644 --- a/bioimageio/core/cli.py +++ b/bioimageio/core/cli.py @@ -46,6 +46,7 @@ from tqdm import tqdm from typing_extensions import assert_never +import bioimageio.spec from bioimageio.spec import ( AnyModelDescr, InvalidDescr, @@ -98,10 +99,8 @@ class ArgMixin(BaseModel, use_attribute_docstrings=True, cli_implicit_flags=True class WithSummaryLogging(ArgMixin): - summary: Union[ - Literal["display"], Path, Sequence[Union[Literal["display"], Path]] - ] = Field( - "display", + summary: Sequence[Union[Literal["display"], Path]] = Field( + ("display",), examples=[ "display", Path("summary.md"), @@ -867,7 +866,7 @@ def run(self): library versions: bioimageio.core {VERSION} - bioimageio.spec {VERSION} + bioimageio.spec {bioimageio.spec.__version__} spec format versions: model RDF {ModelDescr.implemented_format_version} diff --git a/tests/test_bioimageio_collection.py b/tests/test_bioimageio_collection.py index b61299aa..84561eb1 100644 --- a/tests/test_bioimageio_collection.py +++ b/tests/test_bioimageio_collection.py @@ -123,6 +123,7 @@ def yield_bioimageio_yaml_urls() -> Iterable[ParameterSet]: "mellow-takeout/1": "missing cite", "merry-water-buffalo/0.1.0": "requires biapy", "mesmerizing-shoe/1.14.1": "missing license", + "modest-spider/0.1.1": "non-batch id 'b'", "naked-microbe/1": "unknown layer Convolution2D", "nice-peacock/1": "invalid id", "noisy-ox/1": "batch size is actually limited to 1", @@ -151,6 +152,7 @@ def yield_bioimageio_yaml_urls() -> Iterable[ParameterSet]: ), "striking-necktie/1.14.1": "invalid id", "stupendous-sheep/1.1": "requires relativ import of attachment", + "sympathetic-mosquito/1": "error deserializing VarianceScaling", "tempting-pizza/1": "missing license", "timeless-running-shirt/1.13.2": "invalid id, missing license", "uplifting-backpack/1.14.1": "invalid id, missing license",