Skip to content

Commit 255094d

Browse files
committed
respect status 'valid-format' in add_detail()
1 parent 2b4b6a8 commit 255094d

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/bioimageio/spec/summary.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -245,16 +245,22 @@ class ValidationSummary(BaseModel, extra="allow"):
245245

246246
name: str
247247
"""Name of the validation"""
248+
248249
source_name: str
249250
"""Source of the validated bioimageio description"""
251+
250252
id: Optional[str] = None
251253
"""ID of the resource being validated"""
254+
252255
type: str
253256
"""Type of the resource being validated"""
257+
254258
format_version: str
255259
"""Format version of the resource being validated"""
260+
256261
status: Literal["passed", "valid-format", "failed"]
257-
"""overall status of the bioimageio validation"""
262+
"""Overall status of the bioimageio validation"""
263+
258264
metadata_completeness: Annotated[float, annotated_types.Interval(ge=0, le=1)] = 0.0
259265
"""Estimate of completeness of the metadata in the resource description.
260266
@@ -376,10 +382,13 @@ def display(
376382
)
377383

378384
def add_detail(self, detail: ValidationDetail):
379-
if detail.status == "failed":
380-
self.status = "failed"
381-
elif detail.status != "passed":
382-
assert_never(detail.status)
385+
if self.status == "valid-format" and detail.status == "passed":
386+
# once status is valid-format we can only improve to 'passed'
387+
self.status = "passed"
388+
elif self.status == "passed" and detail.status == "failed":
389+
# once status is passed it can only degrade to 'valid-format'
390+
self.status = "valid-format"
391+
# once format is 'failed' it cannot improve (valid-format is set at summary creation)
383392

384393
self.details.append(detail)
385394

0 commit comments

Comments
 (0)