Skip to content

Commit

Permalink
add retest_all workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
FynnBe committed Apr 9, 2024
1 parent c2639bf commit 7b59f88
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 21 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/retest_all.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: retest all bioimageio resources adding to their logs

on: workflow_dispatch
concurrency: retest

jobs:
setup:
runs-on: ubuntu-latest
outputs:
matrix: ${{steps.get_matrix.outputs.matrix}}

steps:
- run: wget ${{vars.S3_HOST}}/${{vars.S3_BUCKET}}/${{vars.S3_FOLDER}}/collection.json
- shell: python
id: get_matrix
run: |
import json, os
with open("collection.json") as f:
collection = json.load(f)
published = [{"id": entry["id"], "v": entry["version"]} for entry in collection["collection"]]
matrix = {"include": published}
with open(os.environ["GITHUB_OUTPUT"], "a") as f:
print(f"matrix={matrix}", file=f)
test:
needs: setup
strategy:
matrix: ${{fromJson(needs.setup.outputs.matrix)}}
uses: bioimage-io/collection/.github/workflows/test_call.yaml@main
with:
resource_id: ${{matrix.id}}
version: ${{matrix.v}}
conclude: 'no'
S3_HOST: ${{vars.S3_HOST}}
S3_BUCKET: ${{vars.S3_BUCKET}}
S3_FOLDER: ${{vars.S3_FOLDER}}
secrets: inherit

# TODO: call emailer
7 changes: 6 additions & 1 deletion .github/workflows/test_call.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ on:
description: "Version number prefixed with 'staged/', e.g. 'staged/1' (testing published versions again is not (yet) implemented)"
required: true
type: string
conclude:
description: "Wether or not to trigger a status update based on test results"
required: false
default: 'yes'
type: string
S3_HOST:
required: true
type: string
Expand Down Expand Up @@ -91,7 +96,7 @@ jobs:

conclude:
needs: [validate_format, test]
if: always() # run even if test job fails
if: (inputs.conclude == 'yes') && always() # run even if test job fails
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
4 changes: 0 additions & 4 deletions bioimageio_collection_backoffice/_backoffice.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ def stage(self, resource_id: str, package_url: str):
def validate_format(self, resource_id: str, version: str):
"""validate a (staged) resource version's bioimageio.yaml"""
rv = get_remote_resource_version(self.client, resource_id, version)
if isinstance(rv, PublishedVersion):
logger.error("Revalidation of published resources is not implemented")
return

dynamic_test_cases, conda_envs = validate_format(rv)
set_gh_actions_outputs(
has_dynamic_test_cases=bool(dynamic_test_cases),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ def maybe_swap_with_thumbnail(
entry["nickname_icon"] = entry["id_emoji"]
entry["entry_source"] = client.get_file_url(rdf_s3_path)
entry["rdf_source"] = entry["entry_source"]
entry["version"] = v
entry["versions"] = versions
return entry

Expand Down
34 changes: 18 additions & 16 deletions bioimageio_collection_backoffice/validate_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from ruyaml import YAML
from typing_extensions import assert_never

from .remote_resource import StagedVersion
from .remote_resource import PublishedVersion, StagedVersion
from .s3_structure.log import BioimageioLog, Logs

yaml = YAML(typ="safe")
Expand Down Expand Up @@ -218,12 +218,14 @@ def prepare_dynamic_test_cases(
return validation_cases, conda_envs


def validate_format(staged: StagedVersion):
if not staged.exists():
raise ValueError(f"{staged} not found")
def validate_format(rv: Union[StagedVersion, PublishedVersion]):
if not rv.exists():
raise ValueError(f"{rv} not found")

staged.set_testing_status("Validating RDF format")
rdf_source = staged.rdf_url
if isinstance(rv, StagedVersion):
rv.set_testing_status("Validating RDF format")

rdf_source = rv.rdf_url
rd = load_description(rdf_source, format_version="discover")
if not isinstance(rd, InvalidDescr):
rd.validation_summary.add_detail(
Expand Down Expand Up @@ -251,15 +253,15 @@ def validate_format(staged: StagedVersion):
rd = rd_latest
rd.validation_summary.status = "passed" # passed in 'discover' mode
if not isinstance(rd, InvalidDescr) and rd.version is not None:
published = staged.get_versions().published
if str(rd.version) in {v.sem_ver for v in published.values()}:
error = ErrorEntry(
loc=("version",),
msg=f"Trying to publish version {rd.version} again!",
type="error",
)
else:
error = None
error = None
if isinstance(rv, StagedVersion):
published = rv.get_versions().published
if str(rd.version) in {v.sem_ver for v in published.values()}:
error = ErrorEntry(
loc=("version",),
msg=f"Trying to publish version {rd.version} again!",
type="error",
)

rd.validation_summary.add_detail(
ValidationDetail(
Expand All @@ -270,5 +272,5 @@ def validate_format(staged: StagedVersion):
)

summary = rd.validation_summary
staged.extend_log(Logs(bioimageio_spec=[BioimageioLog(log=summary)]))
rv.extend_log(Logs(bioimageio_spec=[BioimageioLog(log=summary)]))
return dynamic_test_cases, conda_envs

0 comments on commit 7b59f88

Please sign in to comment.