Skip to content

Commit

Permalink
Merge pull request #12 from bioimage-io/improve_datastructures
Browse files Browse the repository at this point in the history
Improve datastructures
  • Loading branch information
FynnBe authored Mar 12, 2024
2 parents 2c0dd8b + bca4a58 commit 94dd632
Show file tree
Hide file tree
Showing 25 changed files with 721 additions and 425 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ on:
description: "Bioimageio ID of the resource - to be used to access the resource on S3"
required: true
type: string
stage_nr:
description: stage nr to publish
stage_number:
description: stage number to publish
required: true
type: number

Expand All @@ -28,7 +28,7 @@ jobs:
uses: ./.github/workflows/publish_call.yaml
with:
resource_id: ${{inputs.resource_id}}
stage_nr: ${{inputs.stage_nr}}
stage_number: ${{inputs.stage_number}}
S3_HOST: ${{vars.S3_HOST}}
S3_BUCKET: ${{vars.S3_BUCKET}}
S3_FOLDER: ${{vars.S3_FOLDER}}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/publish_call.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ on:
description: "Bioimageio ID of the resource - to be used to access the resource on S3"
required: true
type: string
stage_nr:
description: stage nr to publish
stage_number:
description: stage number to publish
required: true
type: number
S3_HOST:
Expand Down Expand Up @@ -45,7 +45,7 @@ jobs:
python-version: "3.12"
cache: "pip" # caching pip dependencies
- run: pip install .
- run: backoffice publish "${{ inputs.resource_id }}" "${{ inputs.stage_nr }}"
- run: backoffice publish "${{ inputs.resource_id }}" "${{ inputs.stage_number }}"
# - name: Publish to Zenodo
# run: |
# python .github/scripts/update_status.py "${{ inputs.resource_path }}" "Publishing to Zenodo" "5"
Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/request_changes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: request changes

on:
workflow_dispatch:
inputs:
resource_id:
description: "Bioimageio ID of the resource - to be used to access the resource on S3"
required: true
type: string
stage_number:
description: stage number
required: true
type: number
reason:
description: Why are changes required? What needs changing?
required: true
type: string

concurrency: ${{inputs.resource_id}}

env:
S3_HOST: ${{vars.S3_HOST}}
S3_BUCKET: ${{vars.S3_BUCKET}}
S3_FOLDER: ${{vars.S3_FOLDER}}
S3_ACCESS_KEY_ID: ${{secrets.S3_ACCESS_KEY_ID}}
S3_SECRET_ACCESS_KEY: ${{secrets.S3_SECRET_ACCESS_KEY}}
ZENODO_URL: ${{vars.ZENODO_URL}}
ZENODO_API_ACCESS_TOKEN: ${{secrets.ZENODO_API_ACCESS_TOKEN}}

jobs:
call:
uses: ./.github/workflows/request_changes_call.yaml
with:
resource_id: ${{inputs.resource_id}}
stage_number: ${{inputs.stage_number}}
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
52 changes: 52 additions & 0 deletions .github/workflows/request_changes_call.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: request changes call

on:
workflow_call:
inputs:
resource_id:
description: "Bioimageio ID of the resource - to be used to access the resource on S3"
required: true
type: string
stage_number:
description: stage number
required: true
type: number
reason:
description: Why are changes required? What needs changing?
required: true
type: string
S3_HOST:
required: true
type: string
S3_BUCKET:
required: true
type: string
S3_FOLDER:
required: true
type: string
ZENODO_URL:
required: true
type: string

concurrency: ${{inputs.resource_id}}-call

env:
S3_HOST: ${{inputs.S3_HOST}}
S3_BUCKET: ${{inputs.S3_BUCKET}}
S3_FOLDER: ${{inputs.S3_FOLDER}}
ZENODO_URL: ${{inputs.ZENODO_URL}}
S3_ACCESS_KEY_ID: ${{secrets.S3_ACCESS_KEY_ID}}
S3_SECRET_ACCESS_KEY: ${{secrets.S3_SECRET_ACCESS_KEY}}
ZENODO_API_ACCESS_TOKEN: ${{secrets.ZENODO_API_ACCESS_TOKEN}}

jobs:
request-changes:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "pip" # caching pip dependencies
- run: pip install .
- run: backoffice request-changes "${{ inputs.resource_id }}" "${{ inputs.stage_number }}" "${{ inputs.reason }}"
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
uses: ./.github/workflows/publish_call.yaml
with:
resource_id: ${{vars.TEST_PACKAGE_ID}} # testing!
stage_nr: 1
stage_number: 1
S3_HOST: ${{vars.S3_HOST}}
S3_BUCKET: ${{vars.S3_TEST_BUCKET}} # testing!
S3_FOLDER: ${{vars.S3_TEST_FOLDER}}/ci # testing!
Expand Down
23 changes: 14 additions & 9 deletions backoffice/_backoffice.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
from dotenv import load_dotenv

from backoffice.backup import backup
from backoffice.run_dynamic_tests import run_dynamic_tests
from backoffice.utils.remote_resource import (
from backoffice.remote_resource import (
PublishedVersion,
RemoteResource,
StagedVersion,
)
from backoffice.utils.s3_client import Client
from backoffice.run_dynamic_tests import run_dynamic_tests
from backoffice.s3_client import Client
from backoffice.s3_structure.versions import StageNumber
from backoffice.validate_format import validate_format

_ = load_dotenv()
Expand Down Expand Up @@ -44,23 +45,27 @@ def stage(self, resource_id: str, package_url: str):
def test(
self,
resource_id: str,
stage_nr: int,
stage_number: StageNumber,
weight_format: Optional[Union[WeightsFormat, Literal[""]]] = None,
create_env_outcome: Literal["success", ""] = "success",
):
staged = StagedVersion(self.client, resource_id, stage_nr)
staged = StagedVersion(self.client, resource_id, stage_number)
run_dynamic_tests(
staged=staged,
weight_format=weight_format or None,
create_env_outcome=create_env_outcome,
)

def await_review(self, resource_id: str, stage_nr: int):
staged = StagedVersion(self.client, resource_id, stage_nr)
def await_review(self, resource_id: str, stage_number: StageNumber):
staged = StagedVersion(self.client, resource_id, stage_number)
staged.await_review()

def publish(self, resource_id: str, stage_nr: int):
staged = StagedVersion(self.client, resource_id, stage_nr)
def request_changes(self, resource_id: str, stage_number: StageNumber, reason: str):
staged = StagedVersion(self.client, resource_id, stage_number)
staged.request_changes(reason=reason)

def publish(self, resource_id: str, stage_number: StageNumber):
staged = StagedVersion(self.client, resource_id, stage_number)
published = staged.publish()
assert isinstance(published, PublishedVersion)

Expand Down
2 changes: 1 addition & 1 deletion backoffice/backup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from dotenv import load_dotenv
from loguru import logger

from backoffice.utils.s3_client import Client
from backoffice.s3_client import Client

_ = load_dotenv()

Expand Down
File renamed without changes.
Loading

0 comments on commit 94dd632

Please sign in to comment.