Skip to content

Commit 93f5c40

Browse files
authored
Merge pull request #725 from bioimage-io/dev
Fix `ValidationSummary.add_detail()`
2 parents 3f9f201 + 1aeb384 commit 93f5c40

File tree

8 files changed

+33
-14
lines changed

8 files changed

+33
-14
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ jobs:
188188

189189
pip-build:
190190
name: Build and publish to PyPI
191-
needs: [test, conda-build]
191+
needs: [deploy, conda-build]
192192
runs-on: ubuntu-latest
193193
steps:
194194
- name: Check out the repository

changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ In this file we log both:
1010

1111
This changelog includes implementation details and my reference the [changes to the Resource Description Format](#changes-to-the-resource-description-format), e.g. in entry [bioimageio.spec 0.5.2](#bioimageiospec-052).
1212

13+
#### bioimageio.spec 0.5.5.7
14+
15+
- Fix `ValidationSummary.add_detail()` (respect 'valid-format' status)
16+
1317
#### bioimageio.spec 0.5.5.6
1418

1519
- Add BIOIMAGEIO_HTTP_TIMEOUT environment variable to adjust timeout for http requests.

src/bioimageio/spec/_internal/common_nodes.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,18 +233,22 @@ def load(
233233
with all_warnings_context:
234234
_, _, val_warnings = cls._load_impl(deepcopy_yaml_value(data))
235235

236+
format_status = "failed" if errors else "passed"
236237
rd.validation_summary.add_detail(
237238
ValidationDetail(
238239
errors=errors,
239240
name=(
240241
"bioimageio.spec format validation"
241242
f" {rd.type} {cls.implemented_format_version}"
242243
),
243-
status="failed" if errors else "passed",
244+
status=format_status,
244245
warnings=val_warnings,
245-
context=context.summary, # context for format validation detail is identical
246-
)
246+
),
247+
update_status=False, # avoid updating status from 'valid-format' to 'passed', but ...
247248
)
249+
if format_status == "failed":
250+
# ... update status in case of failure
251+
rd.validation_summary.status = "failed"
248252

249253
return rd
250254

src/bioimageio/spec/_package.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ def save_bioimageio_package(
235235
"""Package a bioimageio resource as a zip file.
236236
237237
Args:
238-
rd: bioimageio resource description
238+
source: bioimageio resource description
239239
compression: The numeric constant of compression method.
240240
compression_level: Compression level to use when writing files to the archive.
241241
See https://docs.python.org/3/library/zipfile.html#zipfile.ZipFile
@@ -298,7 +298,7 @@ def save_bioimageio_package_to_stream(
298298
"""Package a bioimageio resource into a stream.
299299
300300
Args:
301-
rd: bioimageio resource description
301+
source: bioimageio resource description
302302
compression: The numeric constant of compression method.
303303
compression_level: Compression level to use when writing files to the archive.
304304
See https://docs.python.org/3/library/zipfile.html#zipfile.ZipFile

src/bioimageio/spec/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
VERSION = "0.5.5.6"
1+
VERSION = "0.5.5.7"

src/bioimageio/spec/summary.py

Lines changed: 16 additions & 6 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
@@ -375,11 +381,15 @@ def display(
375381
include_conda_list=include_conda_list,
376382
)
377383

378-
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)
384+
def add_detail(self, detail: ValidationDetail, update_status: bool = True):
385+
if update_status:
386+
if self.status == "valid-format" and detail.status == "passed":
387+
# once status is 'valid-format' we can only improve to 'passed'
388+
self.status = "passed"
389+
elif self.status == "passed" and detail.status == "failed":
390+
# once status is 'passed' it can only degrade to 'valid-format'
391+
self.status = "valid-format"
392+
# once format is 'failed' it cannot improve
383393

384394
self.details.append(detail)
385395

tests/test_description.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@ def test_no_forward_compatibility(unet2d_data: BioimageioYamlContent):
4343

4444

4545
def test_update_format(unet2d_path_old: str):
46-
updated = update_format(unet2d_path_old)
46+
updated = update_format(unet2d_path_old, perform_io_checks=False)
4747
assert updated.type == "model"
4848
assert updated.format_version == ModelDescr.implemented_format_version

tests/test_example_specs.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ def test_example_descr_paths(
5858
as_latest=False,
5959
exclude_fields_from_roundtrip=EXCLUDE_FIELDS_FROM_ROUNDTRIP.get(key, set()),
6060
bioimageio_json_schema=bioimageio_json_schema,
61+
perform_io_checks=False,
6162
)
6263

6364

0 commit comments

Comments
 (0)