Skip to content

Commit d6a8ff0

Browse files
Improve message for test-model command
1 parent 0385d87 commit d6a8ff0

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

bioimageio/core/__main__.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99

1010
import typer
1111

12-
from bioimageio.core import __version__, prediction, commands, resource_tests
12+
from bioimageio.core import __version__, prediction, commands, resource_tests, load_raw_resource_description
13+
from bioimageio.core.prediction_pipeline import get_weight_formats
1314
from bioimageio.spec.__main__ import app, help_version as help_version_spec
1415
from bioimageio.spec.model.raw_nodes import WeightsFormat
1516

@@ -94,11 +95,21 @@ def test_model(
9495
devices=devices,
9596
decimal=decimal,
9697
)
98+
99+
if weight_format is None:
100+
weight_formats = get_weight_formats()
101+
model_weight_formats = list(load_raw_resource_description(model_rdf).weights.keys())
102+
for wf in weight_formats:
103+
if wf in model_weight_formats:
104+
weight_format = wf
105+
break
106+
weight_format = "unknown" if weight_format is None else weight_format
107+
97108
if summary["error"] is None:
98-
print(f"Model test for {model_rdf} has passed.")
109+
print(f"Model test for {model_rdf} using {weight_format} weight format has passed.")
99110
ret_code = 0
100111
else:
101-
print(f"Model test for {model_rdf} has FAILED!")
112+
print(f"Model test for {model_rdf} using {weight_format} weight format has FAILED!")
102113
print(summary)
103114
ret_code = 1
104115
sys.exit(ret_code)

tests/test_cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ def test_cli_test_model_with_weight_format(unet2d_nuclei_broad_model):
4242

4343

4444
def test_cli_test_resource(unet2d_nuclei_broad_model):
45-
ret = run_subprocess(["bioimageio", "test-model", unet2d_nuclei_broad_model])
45+
ret = run_subprocess(["bioimageio", "test-resource", unet2d_nuclei_broad_model])
4646
assert ret.returncode == 0, ret.stdout
4747

4848

4949
def test_cli_test_resource_with_weight_format(unet2d_nuclei_broad_model):
5050
ret = run_subprocess(
51-
["bioimageio", "test-model", unet2d_nuclei_broad_model, "--weight-format", "pytorch_state_dict"]
51+
["bioimageio", "test-resource", unet2d_nuclei_broad_model, "--weight-format", "pytorch_state_dict"]
5252
)
5353
assert ret.returncode == 0, ret.stdout
5454

0 commit comments

Comments
 (0)