Skip to content

Commit 7a648fd

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 15a9d10 commit 7a648fd

File tree

2 files changed

+48
-27
lines changed

2 files changed

+48
-27
lines changed

control.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "markdown",
5-
"id": "2f454b5b",
5+
"id": "0",
66
"metadata": {},
77
"source": [
88
"# AiiDA control"
@@ -11,7 +11,7 @@
1111
{
1212
"cell_type": "code",
1313
"execution_count": null,
14-
"id": "03c3d207",
14+
"id": "1",
1515
"metadata": {},
1616
"outputs": [],
1717
"source": [
@@ -25,7 +25,7 @@
2525
{
2626
"cell_type": "code",
2727
"execution_count": null,
28-
"id": "56f4a261",
28+
"id": "2",
2929
"metadata": {},
3030
"outputs": [],
3131
"source": [

home/control.py

Lines changed: 45 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import subprocess
2-
from aiida import engine
3-
import ipywidgets as ipw
2+
43
import aiidalab_widgets_base as awb
5-
from aiida import orm, manage
4+
import ipywidgets as ipw
65
import plumpy
76
import traitlets as tr
7+
from aiida import engine, manage
88
from IPython.display import clear_output
9-
import subprocess
9+
1010

1111
class DaemonControlWidget(ipw.VBox):
1212
def __init__(self, *args, **kwargs):
@@ -22,12 +22,20 @@ def __init__(self, *args, **kwargs):
2222
stop_button.on_click(self._stop_daemon)
2323

2424
# Restart daemon.
25-
restart_button = ipw.Button(description="Restart daemon", button_style="warning")
25+
restart_button = ipw.Button(
26+
description="Restart daemon", button_style="warning"
27+
)
2628
restart_button.on_click(self._restart_daemon)
2729

28-
self.info=ipw.HTML()
30+
self.info = ipw.HTML()
2931
self._update_status()
30-
super().__init__(children=[self.info, self._status, ipw.HBox([start_button, stop_button, restart_button])])
32+
super().__init__(
33+
children=[
34+
self.info,
35+
self._status,
36+
ipw.HBox([start_button, stop_button, restart_button]),
37+
]
38+
)
3139

3240
def _restart_daemon(self, _=None):
3341
self._clear_status()
@@ -56,37 +64,48 @@ def _stop_daemon(self, _=None):
5664
def _update_status(self, _=None):
5765
self._clear_status()
5866
with self._status:
59-
result = subprocess.run(["verdi", "daemon", "status"], capture_output=True, text=True)
67+
result = subprocess.run(
68+
["verdi", "daemon", "status"], capture_output=True, text=True, check=False
69+
)
6070
print(result.stdout, result.stderr)
61-
71+
6272
def _clear_status(self):
6373
with self._status:
6474
clear_output()
6575

6676

67-
6877
class ProcessControlWidget(ipw.VBox):
6978
def __init__(self):
7079
process_list = awb.ProcessListWidget(path_to_root="../../")
71-
past_days_widget = ipw.IntText(value=7, description='Past days:')
72-
tr.link((past_days_widget, 'value'), (process_list, 'past_days'))
80+
past_days_widget = ipw.IntText(value=7, description="Past days:")
81+
tr.link((past_days_widget, "value"), (process_list, "past_days"))
7382

7483
all_days_checkbox = ipw.Checkbox(description="All days", value=True)
75-
tr.dlink((all_days_checkbox, 'value'), (past_days_widget, 'disabled'))
76-
tr.dlink((all_days_checkbox, 'value'), (process_list, 'past_days'), transform=lambda v: -1 if v else past_days_widget.value)
84+
tr.dlink((all_days_checkbox, "value"), (past_days_widget, "disabled"))
85+
tr.dlink(
86+
(all_days_checkbox, "value"),
87+
(process_list, "past_days"),
88+
transform=lambda v: -1 if v else past_days_widget.value,
89+
)
7790

7891
available_states = [state.value for state in plumpy.ProcessState]
79-
process_state_widget = ipw.SelectMultiple(options=available_states,
80-
value=["running", "waiting"],
81-
description='Process State:',
82-
style={'description_width': 'initial'},
83-
disabled=False)
84-
tr.dlink((process_state_widget, 'value'), (process_list, 'process_states'))
92+
process_state_widget = ipw.SelectMultiple(
93+
options=available_states,
94+
value=["running", "waiting"],
95+
description="Process State:",
96+
style={"description_width": "initial"},
97+
disabled=False,
98+
)
99+
tr.dlink((process_state_widget, "value"), (process_list, "process_states"))
85100
process_list.update()
86101

87-
88-
super().__init__(children=[ipw.HBox([past_days_widget, all_days_checkbox]), process_state_widget, process_list])
89-
102+
super().__init__(
103+
children=[
104+
ipw.HBox([past_days_widget, all_days_checkbox]),
105+
process_state_widget,
106+
process_list,
107+
]
108+
)
90109

91110

92111
class GroupControlWidget(ipw.VBox):
@@ -98,7 +117,9 @@ def __init__(self):
98117
class StatusControlWidget(ipw.HTML):
99118
def __init__(self):
100119
print("AiiDA status")
101-
print(subprocess.run(["verdi", "status"], capture_output=True, text=True).stdout)
120+
print(
121+
subprocess.run(["verdi", "status"], capture_output=True, text=True, check=False).stdout
122+
)
102123
super().__init__()
103124

104125

0 commit comments

Comments
 (0)