Skip to content

Commit

Permalink
Merge pull request #56 from bioimage-io/maintainers
Browse files Browse the repository at this point in the history
block new version upload for non-maintainers
  • Loading branch information
FynnBe authored Apr 26, 2024
2 parents c648eff + 9f2fc09 commit bee0e07
Show file tree
Hide file tree
Showing 8 changed files with 174 additions and 63 deletions.
4 changes: 2 additions & 2 deletions bioimageio_collection_backoffice/_backoffice.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def request_changes(
f"Requesting changes of already published {resource_id} {version} is not implemented"
)

rv.request_changes(reviewer=reviewer, reason=reason)
rv.request_changes(reviewer, reason=reason)
notify_uploader(
rv,
"needs changes 📑",
Expand All @@ -129,7 +129,7 @@ def publish(self, resource_id: str, version: str, reviewer: str):

try:
rv.lock_publish()
published: PublishedVersion = rv.publish(reviewer=reviewer)
published: PublishedVersion = rv.publish(reviewer)
assert isinstance(published, PublishedVersion)
self.generate_collection_json()
notify_uploader(
Expand Down
10 changes: 10 additions & 0 deletions bioimageio_collection_backoffice/db_structure/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ class _LogEntryBaseWithDefaults(_LogEntryBase, frozen=True):
"""creation of log entry"""


class CollectionLog(_LogEntryBase, frozen=True):
log: str


class CollectionLogWithDefaults(_LogEntryBaseWithDefaults, CollectionLog, frozen=True):
pass


class BioimageioLog(_LogEntryBase, frozen=True):
log: ValidationSummary

Expand All @@ -37,6 +45,7 @@ class Log(Node, frozen=True, extra="allow"):

bioimageio_spec: Sequence[BioimageioLog]
bioimageio_core: Sequence[BioimageioLog]
collection: Sequence[CollectionLog]

def get_updated(self, update: Log):
v: Union[Any, Sequence[Any]]
Expand All @@ -59,3 +68,4 @@ class LogWithDefaults(Log, frozen=True, extra="allow"):

bioimageio_spec: Sequence[BioimageioLogWithDefaults] = Field(default_factory=list)
bioimageio_core: Sequence[BioimageioLogWithDefaults] = Field(default_factory=list)
collection: Sequence[CollectionLogWithDefaults] = Field(default_factory=list)
7 changes: 6 additions & 1 deletion bioimageio_collection_backoffice/generate_collection_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
from typing import Any, Dict, List, Union

from bioimageio.spec import ValidationContext, build_description
from bioimageio.spec._internal.io import (
get_sha256, # TODO: use bioimageio.spec.utils.get_sha256
)
from bioimageio.spec.collection import CollectionDescr
from bioimageio.spec.common import HttpUrl
from bioimageio.spec.utils import download
Expand Down Expand Up @@ -48,7 +51,8 @@ def create_entry(
with ValidationContext(perform_io_checks=False):
rdf_url = HttpUrl(p.rdf_url)

rdf = yaml.load(download(rdf_url).path)
rdf_path = download(rdf_url).path
rdf = yaml.load(rdf_path)
entry = {
k: rdf[k]
for k in (
Expand Down Expand Up @@ -102,6 +106,7 @@ def maybe_swap_with_thumbnail(
entry["nickname"] = entry["id"]
entry["nickname_icon"] = entry["id_emoji"]
entry["entry_source"] = p.rdf_url
entry["entry_sha256"] = get_sha256(rdf_path)
entry["rdf_source"] = entry["entry_source"]
entry["version_number"] = p.number
entry["versions"] = list(p.concept.versions.published)
Expand Down
5 changes: 3 additions & 2 deletions bioimageio_collection_backoffice/mailroom/_send_email.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import smtplib
import sys
from email.mime.text import MIMEText
from typing import List, Union

Expand All @@ -23,8 +24,8 @@ def notify_uploader(
):
email, name = rv.get_uploader()
if email is None:
logger.error("missing uploader email for {} {}", rv.id, rv.version)
return
rv.report_error(f"missing uploader email for {rv.id} {rv.version}")
sys.exit(1)

subject = f"{STATUS_UPDATE_SUBJECT}{rv.id} {rv.version} {subject_end.strip()}"
if email == BOT_EMAIL:
Expand Down
Loading

0 comments on commit bee0e07

Please sign in to comment.