diff --git a/control.ipynb b/control.ipynb index ce07a3e..a5a58ad 100644 --- a/control.ipynb +++ b/control.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "2f454b5b", + "id": "0", "metadata": {}, "source": [ "# AiiDA control" @@ -11,7 +11,7 @@ { "cell_type": "code", "execution_count": null, - "id": "03c3d207", + "id": "1", "metadata": {}, "outputs": [], "source": [ @@ -25,7 +25,7 @@ { "cell_type": "code", "execution_count": null, - "id": "56f4a261", + "id": "2", "metadata": {}, "outputs": [], "source": [ diff --git a/home/control.py b/home/control.py index 71702b5..081f64e 100644 --- a/home/control.py +++ b/home/control.py @@ -1,12 +1,12 @@ import subprocess -from aiida import engine -import ipywidgets as ipw + import aiidalab_widgets_base as awb -from aiida import orm, manage +import ipywidgets as ipw import plumpy import traitlets as tr +from aiida import engine, manage from IPython.display import clear_output -import subprocess + class DaemonControlWidget(ipw.VBox): def __init__(self, *args, **kwargs): @@ -22,12 +22,20 @@ def __init__(self, *args, **kwargs): stop_button.on_click(self._stop_daemon) # Restart daemon. - restart_button = ipw.Button(description="Restart daemon", button_style="warning") + restart_button = ipw.Button( + description="Restart daemon", button_style="warning" + ) restart_button.on_click(self._restart_daemon) - self.info=ipw.HTML() + self.info = ipw.HTML() self._update_status() - super().__init__(children=[self.info, self._status, ipw.HBox([start_button, stop_button, restart_button])]) + super().__init__( + children=[ + self.info, + self._status, + ipw.HBox([start_button, stop_button, restart_button]), + ] + ) def _restart_daemon(self, _=None): self._clear_status() @@ -56,37 +64,48 @@ def _stop_daemon(self, _=None): def _update_status(self, _=None): self._clear_status() with self._status: - result = subprocess.run(["verdi", "daemon", "status"], capture_output=True, text=True) + result = subprocess.run( + ["verdi", "daemon", "status"], capture_output=True, text=True, check=False + ) print(result.stdout, result.stderr) - + def _clear_status(self): with self._status: clear_output() - class ProcessControlWidget(ipw.VBox): def __init__(self): process_list = awb.ProcessListWidget(path_to_root="../../") - past_days_widget = ipw.IntText(value=7, description='Past days:') - tr.link((past_days_widget, 'value'), (process_list, 'past_days')) + past_days_widget = ipw.IntText(value=7, description="Past days:") + tr.link((past_days_widget, "value"), (process_list, "past_days")) all_days_checkbox = ipw.Checkbox(description="All days", value=True) - tr.dlink((all_days_checkbox, 'value'), (past_days_widget, 'disabled')) - tr.dlink((all_days_checkbox, 'value'), (process_list, 'past_days'), transform=lambda v: -1 if v else past_days_widget.value) + tr.dlink((all_days_checkbox, "value"), (past_days_widget, "disabled")) + tr.dlink( + (all_days_checkbox, "value"), + (process_list, "past_days"), + transform=lambda v: -1 if v else past_days_widget.value, + ) available_states = [state.value for state in plumpy.ProcessState] - process_state_widget = ipw.SelectMultiple(options=available_states, - value=["running", "waiting"], - description='Process State:', - style={'description_width': 'initial'}, - disabled=False) - tr.dlink((process_state_widget, 'value'), (process_list, 'process_states')) + process_state_widget = ipw.SelectMultiple( + options=available_states, + value=["running", "waiting"], + description="Process State:", + style={"description_width": "initial"}, + disabled=False, + ) + tr.dlink((process_state_widget, "value"), (process_list, "process_states")) process_list.update() - - super().__init__(children=[ipw.HBox([past_days_widget, all_days_checkbox]), process_state_widget, process_list]) - + super().__init__( + children=[ + ipw.HBox([past_days_widget, all_days_checkbox]), + process_state_widget, + process_list, + ] + ) class GroupControlWidget(ipw.VBox): @@ -98,7 +117,9 @@ def __init__(self): class StatusControlWidget(ipw.HTML): def __init__(self): print("AiiDA status") - print(subprocess.run(["verdi", "status"], capture_output=True, text=True).stdout) + print( + subprocess.run(["verdi", "status"], capture_output=True, text=True, check=False).stdout + ) super().__init__()