5
5
from IPython .display import Javascript , display
6
6
7
7
from aiida import orm
8
+ from aiida .common .exceptions import NotExistent
8
9
from aiida .engine import ProcessBuilderNamespace , submit
9
10
from aiida .orm .utils .serialize import serialize
10
11
from aiidalab_qe .app .parameters import DEFAULT_PARAMETERS
11
- from aiidalab_qe .common .mixins import HasInputStructure , HasModels
12
+ from aiidalab_qe .common .mixins import HasInputStructure , HasModels , HasProcess
12
13
from aiidalab_qe .common .panel import PluginResourceSettingsModel , ResourceSettingsModel
13
14
from aiidalab_qe .common .wizard import QeConfirmableWizardStepModel
14
15
from aiidalab_qe .utils import shallow_copy_nested_dict
@@ -21,12 +22,12 @@ class SubmissionStepModel(
21
22
QeConfirmableWizardStepModel ,
22
23
HasModels [ResourceSettingsModel ],
23
24
HasInputStructure ,
25
+ HasProcess ,
24
26
):
25
27
identifier = "submission"
26
28
27
29
input_parameters = tl .Dict ()
28
30
29
- process_node = tl .Instance (orm .WorkChainNode , allow_none = True )
30
31
process_label = tl .Unicode ("" )
31
32
process_description = tl .Unicode ("" )
32
33
@@ -60,7 +61,7 @@ def __init__(self, *args, **kwargs):
60
61
61
62
def confirm (self ):
62
63
super ().confirm ()
63
- if not self .process_node :
64
+ if not self .has_process :
64
65
self ._submit ()
65
66
66
67
def update (self ):
@@ -163,15 +164,22 @@ def set_model_state(self, state: dict):
163
164
model .set_model_state (codes [identifier ])
164
165
model .locked = True
165
166
166
- if self .process_node :
167
- self .process_label = self .process_node .label
168
- self .process_description = self .process_node .description
167
+ self ._update_process_metadata ()
168
+
169
+ def _update_process_metadata (self ):
170
+ if not self .has_process :
171
+ return
172
+ try :
173
+ self .process_label = self .process .label
174
+ self .process_description = self .process .description
169
175
self .locked = True
176
+ except NotExistent :
177
+ return
170
178
171
179
def reset (self ):
172
180
with self .hold_trait_notifications ():
173
181
self .input_parameters = {}
174
- self .process_node = None
182
+ self .process_uuid = None
175
183
for identifier , model in self .get_models ():
176
184
if identifier not in self ._default_models :
177
185
model .include = False
@@ -194,13 +202,10 @@ def _submit(self):
194
202
"structure" ,
195
203
self .input_structure .get_formula (),
196
204
)
197
- self .process_node = process_node
198
-
199
- self ._update_url ()
205
+ self .process_uuid = process_node .uuid
200
206
201
- def _update_url (self ):
202
- pk = self .process_node .pk
203
- display (Javascript (f"window.history.pushState(null, '', '?pk={ pk } ');" ))
207
+ pk = process_node .pk
208
+ display (Javascript (f"window.history.pushState(null, '', '?pk={ pk } ');" ))
204
209
205
210
def _link_model (self , model : ResourceSettingsModel ):
206
211
for dependency in model .dependencies :
0 commit comments