Skip to content

Commit

Permalink
Merge pull request #31 from bioimage-io/check_reviewer
Browse files Browse the repository at this point in the history
Check reviewer
  • Loading branch information
FynnBe authored Apr 10, 2024
2 parents 59b632f + 3af661b commit 9d98375
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 21 deletions.
1 change: 0 additions & 1 deletion .github/workflows/build_backoffice.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ jobs:
with:
resource_id: ${{vars.TEST_PACKAGE_ID}} # testing!
stage_number: 1
reviewer: test
S3_HOST: ${{vars.S3_HOST}}
S3_BUCKET: ${{vars.S3_TEST_BUCKET}} # testing!
S3_FOLDER: ${{vars.S3_TEST_FOLDER}}/ci # testing!
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ on:
required: true
type: number
reviewer:
description: Name of bioimage.io maintainer accepting this resource version
required: true
description: GitHub account name of bioimage.io maintainer accepting this resource version
required: false
default: 'auto detect'
type: string
sandbox:
description: Flag to publish within sandbox instead
Expand All @@ -30,7 +31,7 @@ jobs:
with:
resource_id: ${{inputs.resource_id}}
stage_number: ${{fromJson(inputs.stage_number)}} # wo 'fromJson' the number is given as string, see https://github.com/orgs/community/discussions/67182
reviewer: ${{inputs.reviewer}}
reviewer: ${{inputs.reviewer == 'auto detect' && github.actor || inputs.reviewer}}
S3_HOST: ${{vars.S3_HOST}}
S3_BUCKET: ${{vars.S3_BUCKET}}
S3_FOLDER: ${{inputs.sandbox && vars.S3_SANDBOX_FOLDER || vars.S3_FOLDER}}
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/publish_call.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ on:
required: true
type: number
reviewer:
description: Name of bioimage.io maintainer accepting this resource version
required: true
description: GitHub account name of bioimage.io maintainer accepting this resource version
required: false
default: ${{github.actor}}
type: string
S3_HOST:
required: true
Expand All @@ -39,6 +40,9 @@ jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: reject reviewer id
run: exit 1
if: github.actor != 'bioimageiobot' && github.actor != inputs.reviewer
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
Expand Down
21 changes: 11 additions & 10 deletions .github/workflows/request_changes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ on:
required: true
type: number
reviewer:
description: Name of bioimage.io maintainer requesting changes
required: true
description: GitHub account name of bioimage.io maintainer requesting changes
required: false
default: 'auto detect'
type: string
reason:
description: Why are changes required? What needs changing?
Expand All @@ -27,12 +28,12 @@ jobs:
call:
uses: bioimage-io/collection/.github/workflows/request_changes_call.yaml@main
with:
resource_id: '${{inputs.resource_id}}'
stage_number: '${{fromJson(inputs.stage_number)}}' # wo 'fromJson' the number is given as string, see https://github.com/orgs/community/discussions/67182
reviewer: '${{inputs.reviewer}}'
reason: '${{inputs.reason}}'
S3_HOST: '${{vars.S3_HOST}}'
S3_BUCKET: '${{vars.S3_BUCKET}}'
S3_FOLDER: '${{vars.S3_FOLDER}}'
ZENODO_URL: '${{vars.ZENODO_URL}}'
resource_id: ${{inputs.resource_id}}
stage_number: ${{fromJson(inputs.stage_number)}} # wo 'fromJson' the number is given as string, see https://github.com/orgs/community/discussions/67182
reviewer: ${{inputs.reviewer == 'auto detect' && github.actor || inputs.reviewer}}
reason: ${{inputs.reason}}
S3_HOST: ${{vars.S3_HOST}}
S3_BUCKET: ${{vars.S3_BUCKET}}
S3_FOLDER: ${{vars.S3_FOLDER}}
ZENODO_URL: ${{vars.ZENODO_URL}}
secrets: inherit
8 changes: 6 additions & 2 deletions .github/workflows/request_changes_call.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ on:
required: true
type: number
reviewer:
description: Name of bioimage.io maintainer requesting changes
required: true
description: GitHub account name of bioimage.io maintainer requesting changes
required: false
default: ${{github.actor}}
type: string
reason:
description: Why are changes required? What needs changing?
Expand Down Expand Up @@ -47,6 +48,9 @@ jobs:
request-changes:
runs-on: ubuntu-latest
steps:
- name: reject reviewer id
run: exit 1
if: github.actor != 'bioimageiobot' && github.actor != inputs.reviewer
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
Expand Down
5 changes: 4 additions & 1 deletion bioimageio_collection_backoffice/remote_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from typing_extensions import assert_never

from ._thumbnails import create_thumbnails
from .reviewer import REVIEWERS
from .s3_client import Client
from .s3_structure.chat import Chat, Message
from .s3_structure.log import Logs
Expand Down Expand Up @@ -319,6 +320,7 @@ def await_review(self):
self._set_status(AwaitingReviewStatus())

def request_changes(self, reviewer: str, reason: str):
reviewer = REVIEWERS[reviewer.lower()] # map to reviewer name
self._set_status(ChangesRequestedStatus(description=reason))
self.extend_chat(
Chat(
Expand All @@ -330,11 +332,12 @@ def request_changes(self, reviewer: str, reason: str):
)
)

def mark_as_superseded(self, description: str, by: StageNumber):
def mark_as_superseded(self, description: str, by: StageNumber): # TODO: use this!
self._set_status(SupersededStatus(description=description, by=by))

def publish(self, reviewer: str) -> PublishedVersion:
"""mark this staged version candidate as accepted and try to publish it"""
reviewer = REVIEWERS[reviewer.lower()] # map to reviewer name
self._set_status(AcceptedStatus())
self.extend_chat(
Chat(
Expand Down
13 changes: 13 additions & 0 deletions bioimageio_collection_backoffice/reviewer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import os
from typing import Dict

import requests

# load mapping of GitHub account names to plain names for bioimage.io maintainers
REVIEWERS: Dict[str, str] = requests.get(os.environ["REVIEWERS"]).json()
assert all(
r.lower() == r for r in REVIEWERS
), "Maintainer GitHub account name has to be lower case"
assert all(
isinstance(name, str) for name in REVIEWERS
), "Maintainer name has to be string"
2 changes: 1 addition & 1 deletion tests/test_backoffice.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ def test_backoffice(
backoffice.stage(resource_id=package_id, package_url=package_url)
backoffice.test(resource_id=package_id, version="staged/1")
backoffice.await_review(resource_id=package_id, version="staged/1")
backoffice.publish(resource_id=package_id, version="staged/1", reviewer="test")
backoffice.publish(resource_id=package_id, version="staged/1", reviewer="fynnbe")
backoffice.generate_collection_json()
backoffice.backup(os.environ["ZENODO_TEST_URL"])
2 changes: 1 addition & 1 deletion tests/test_utils/test_remote_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def test_lifecycle(
== f"{s3_test_folder_url}frank-water-buffalo/staged/1/files/rdf.yaml"
)
# skipping test step here (tested in test_backoffice)
published = staged.publish(reviewer="test")
published = staged.publish(reviewer="fynnbe")
assert isinstance(published, PublishedVersion)
published_rdf_url = published.rdf_url
assert (
Expand Down

0 comments on commit 9d98375

Please sign in to comment.