11import subprocess
2- from aiida import engine
3- import ipywidgets as ipw
2+
43import aiidalab_widgets_base as awb
5- from aiida import orm , manage
4+ import ipywidgets as ipw
65import plumpy
76import traitlets as tr
7+ from aiida import engine , manage
88from IPython .display import clear_output
9- import subprocess
9+
1010
1111class 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-
6877class 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
92111class GroupControlWidget (ipw .VBox ):
@@ -98,7 +117,9 @@ def __init__(self):
98117class 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