Skip to content

Commit

Permalink
Merge pull request #115 from bioimage-io/pretty_status
Browse files Browse the repository at this point in the history
Prettier status
  • Loading branch information
FynnBe authored Nov 14, 2024
2 parents bff9dfa + 93ae1ff commit efb7f06
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
11 changes: 10 additions & 1 deletion bioimageio_collection_backoffice/db_structure/version_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
class _StatusBase(Node, frozen=True):
timestamp: datetime = pydantic.Field(default_factory=datetime.now)
run_url: Optional[str] = settings.run_url
icon: str = "🛈"


class _DraftStatusBase(_StatusBase, frozen=True):
Expand All @@ -35,31 +36,36 @@ def _validate_num_steps(self):
class UnpackingStatus(_DraftStatusBase, frozen=True):
name: Literal["unpacking"] = "unpacking"
step: Literal[1] = 1
icon: str = "📦"


class UnpackedStatus(_DraftStatusBase, frozen=True):
name: Literal["unpacked"] = "unpacked"
description: str = "staging was successful; awaiting automated tests to start ⏳"
step: Literal[2] = 2
icon: str = "⏳"


class TestingStatus(_DraftStatusBase, frozen=True):
name: Literal["testing"] = "testing"
step: Literal[3] = 3
icon: str = "🧪"


class AwaitingReviewStatus(_DraftStatusBase, frozen=True):
name: Literal["awaiting review"] = "awaiting review"
description: str = (
"Thank you for your contribution! 💪"
"Our bioimage.io maintainers will take a look soon. 🦒"
"Our bioimage.io maintainers will take a look soon."
)
step: Literal[4] = 4
icon: str = "🧐"


class ChangesRequestedStatus(_DraftStatusBase, frozen=True):
name: Literal["changes requested"] = "changes requested"
step: Literal[5] = 5
icon: str = "🔧"


class AcceptedStatus(_DraftStatusBase, frozen=True):
Expand All @@ -68,6 +74,7 @@ class AcceptedStatus(_DraftStatusBase, frozen=True):
"This staged version has been accepted by a bioimage.io maintainer and is about to be published."
)
step: Literal[5] = 5
icon: str = "👍"


class PublishedDraftStatus(_DraftStatusBase, frozen=True):
Expand All @@ -76,6 +83,7 @@ class PublishedDraftStatus(_DraftStatusBase, frozen=True):
name: Literal["published"] = "published"
description: str = "published! (this draft will be deleted shortly)"
step: Literal[6] = 6
icon: str = "🎉"


DraftStatus = Annotated[
Expand All @@ -98,6 +106,7 @@ class ErrorStatus(_StatusBase, frozen=True):
message: str
traceback: List[str]
during: Optional[DraftStatus]
icon: str = "🔴"


class DraftInfo(Node, frozen=True):
Expand Down
17 changes: 8 additions & 9 deletions bioimageio_collection_backoffice/remote_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -867,18 +867,17 @@ def request_changes(self, reviewer: str, reason: str):
# map reviewer id to name
for r in self.collection.config.reviewers:
if reviewer == r.id:
reviewer = r.name
break
else:
raise ValueError(reviewer)

self._set_status(ChangesRequestedStatus(description=reason))
description = (
f'<a href= "mailto: {r.email}"> {r.name}</a> requested changes: {reason}'
)
plain_description = f"{r.name} requested changes: {reason}"
self._set_status(ChangesRequestedStatus(description=description))
self.extend_chat(
Chat(
messages=[
Message(
author="system", text=f"{reviewer} requested changes: {reason}"
)
]
)
Chat(messages=[Message(author="system", text=plain_description)])
)

@log
Expand Down

0 comments on commit efb7f06

Please sign in to comment.