@@ -196,26 +196,38 @@ def check_already_success(self):
196
196
job .status = "wait"
197
197
198
198
def init_callback (self ):
199
- for name in ["init" , "call_back" ]:
200
- cmd = self .conf .rget ("args" , name )
201
- if not cmd :
202
- continue
199
+ self .add_init (self .conf .rget ("args" , "init" ))
200
+ self .add_callback (self .conf .rget ("args" , "call_back" ))
201
+
202
+ def add_init (self , init = "" ):
203
+ if init :
204
+ if "init" in self .totaljobdict :
205
+ job = self .totaljobdict ["init" ]
206
+ return self .logger .error ("init '%s' exists" , job .rawstring )
203
207
job = Job (self .conf )
204
- job = job .from_cmd (self .jfile , linenum = - 1 , cmd = cmd )
205
- job .to_local (jobname = name , removelog = False )
206
- self .totaljobdict [name ] = job
207
- if name == "init" :
208
- self .jobs .insert (0 , job )
209
- f = self .jobsgraph .ind_nodes ()
210
- self .jobsgraph .add_node_if_not_exists (job .jobname )
211
- for j in f :
212
- self .jobsgraph .add_edge (name , j )
213
- else :
214
- self .jobs .append (job )
215
- f = self .jobsgraph .end_nodes ()
216
- self .jobsgraph .add_node_if_not_exists (job .jobname )
217
- for j in f :
218
- self .jobsgraph .add_edge (j , name )
208
+ job = job .from_cmd (self .jfile , linenum = - 1 , cmd = init )
209
+ job .to_local (jobname = "init" , removelog = False )
210
+ self .totaljobdict ["init" ] = job
211
+ self .jobs .insert (0 , job )
212
+ ind_nodes = self .jobsgraph .ind_nodes ()
213
+ self .jobsgraph .add_node_if_not_exists (job .jobname )
214
+ for j in ind_nodes :
215
+ self .jobsgraph .add_edge ("init" , j )
216
+
217
+ def add_callback (self , callback = "" ):
218
+ if callback :
219
+ if "callback" in self .totaljobdict :
220
+ job = self .totaljobdict ["callback" ]
221
+ return self .logger .error ("callback '%s' exists" , job .rawstring )
222
+ job = Job (self .conf )
223
+ job = job .from_cmd (self .jfile , linenum = - 1 , cmd = callback )
224
+ job .to_local (jobname = "callback" , removelog = False )
225
+ self .totaljobdict ["callback" ] = job
226
+ self .jobs .append (job )
227
+ end_nodes = self .jobsgraph .end_nodes ()
228
+ self .jobsgraph .add_node_if_not_exists (job .jobname )
229
+ for j in end_nodes :
230
+ self .jobsgraph .add_edge (j , "callback" )
219
231
220
232
def log_status (self , job ):
221
233
name = job .jobname
0 commit comments