Skip to content

Commit 7fea808

Browse files
committed
add summary_path arg
1 parent ee87863 commit 7fea808

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

bioimageio/core/cli.py

+4
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,17 @@ class TestCmd(CmdBase, WithSource):
133133
decimal: int = 4
134134
"""Precision for numerical comparisons"""
135135

136+
summary_path: Optional[Path] = None
137+
"""Path to save validation summary as JSON file."""
138+
136139
def run(self):
137140
sys.exit(
138141
test(
139142
self.descr,
140143
weight_format=self.weight_format,
141144
devices=self.devices,
142145
decimal=self.decimal,
146+
summary_path=self.summary_path,
143147
)
144148
)
145149

bioimageio/core/commands.py

+6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""These functions implement the logic of the bioimageio command line interface
22
defined in `bioimageio.core.cli`."""
33

4+
import json
45
from pathlib import Path
56
from typing import Optional, Sequence, Union
67

@@ -26,6 +27,7 @@ def test(
2627
weight_format: WeightFormatArgAll = "all",
2728
devices: Optional[Union[str, Sequence[str]]] = None,
2829
decimal: int = 4,
30+
summary_path: Optional[Path] = None,
2931
) -> int:
3032
"""test a bioimageio resource
3133
@@ -35,6 +37,7 @@ def test(
3537
weight_format: (model only) The weight format to use
3638
devices: Device(s) to use for testing
3739
decimal: Precision for numerical comparisons
40+
summary_path: Path to save validation summary as JSON file.
3841
"""
3942
if isinstance(descr, InvalidDescr):
4043
descr.validation_summary.display()
@@ -47,6 +50,9 @@ def test(
4750
decimal=decimal,
4851
)
4952
summary.display()
53+
if summary_path is not None:
54+
_ = summary_path.write_text(summary.model_dump_json(indent=4))
55+
5056
return 0 if summary.status == "passed" else 1
5157

5258

0 commit comments

Comments
 (0)