Skip to content

Commit

Permalink
Merge branch 'main' into plugin/api_add_update_input
Browse files Browse the repository at this point in the history
  • Loading branch information
superstar54 authored Apr 9, 2024
2 parents 8a2e4b3 + 86f4aac commit ce9f4f0
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions src/aiidalab_qe/app/result/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
# trigger registration of the viewer widget:
from .workchain_viewer import WorkChainViewer # noqa: F401

PROCESS_COMPLETED = "<h4>Workflow completed successfully!</h4>"
PROCESS_EXCEPTED = "<h4>Workflow is excepted!</h4>"
PROCESS_RUNNING = "<h4>Workflow is running!</h4>"


class ViewQeAppWorkChainStatusAndResultsStep(ipw.VBox, WizardAppWidgetStep):
process = tl.Unicode(allow_none=True)
Expand Down Expand Up @@ -50,8 +54,15 @@ def __init__(self, **kwargs):
layout=ipw.Layout(width="120px", height="40px"),
)
self.kill_button.on_click(self._on_click_kill_button)
self.process_info = ipw.HTML()

super().__init__([self.kill_button, self.process_status], **kwargs)
super().__init__(
[
ipw.HBox(children=[self.kill_button, self.process_info]),
self.process_status,
],
**kwargs,
)

self._update_kill_button_layout()

Expand All @@ -75,21 +86,31 @@ def _update_state(self):
ProcessState.WAITING,
):
self.state = self.State.ACTIVE
self.process_info.value = PROCESS_RUNNING
elif (
process_state in (ProcessState.EXCEPTED, ProcessState.KILLED)
or process.is_failed
):
self.state = self.State.FAIL
self.kill_button.layout.display = "none"
self.process_info.value = PROCESS_EXCEPTED
elif process.is_finished_ok:
self.state = self.State.SUCCESS
self.kill_button.layout.display = "none"
self.process_info.value = PROCESS_COMPLETED

def _update_kill_button_layout(self):
"""Update the layout of the kill button."""
# If no process is selected, hide the button.
if self.process is None:
if self.process is None or self.process == "":
self.kill_button.layout.display = "none"
else:
self.kill_button.layout.display = "block"
process = orm.load_node(self.process)
# If the process is finished or excepted, hide the button.
if process.is_finished or process.is_excepted:
self.kill_button.layout.display = "none"
else:
self.kill_button.layout.display = "block"

# If the step is not activated, no point to click the button, so disable it.
# Only enable it if the process is on (RUNNING, CREATED, WAITING).
Expand Down

0 comments on commit ce9f4f0

Please sign in to comment.