@@ -304,57 +304,87 @@ def replace_event_file(params, files):
304
304
return ret_status , with_events , with_order_id_map , params_map
305
305
306
306
307
- deliver_input_files (sys .argv [3 ], sys .argv [4 ], sys .argv [5 ])
308
- cmd_line = str (binascii .unhexlify (sys .argv [1 ]).decode ())
309
- data_params = sys .argv [2 ]
310
- cmd_line = replace_environment_vars (cmd_line )
311
-
312
- print (f"cmd_line: { cmd_line } " )
313
- print (f"data_params: { data_params } " )
314
-
315
- # If EventService is enabled, data_params will only contain event information.
316
- # So we need to convert the event information to LSST pseudo file names.
317
- # If EventService is not enabled, this part will not change data_params.
318
- ret_rep = replace_event_file (data_params , sys .argv [4 ])
319
- ret_event_status , with_events , with_order_id_map , event_params_map = ret_rep
320
- print (
321
- f"ret_event_status: { ret_event_status } , with_events: { with_events } with_order_id_map: { with_order_id_map } "
322
- )
323
- if not ret_event_status :
324
- print ("failed to map EventService/orderIdMap parameters to original LSST pseudo file names" )
325
- exit_code = 1
326
- sys .exit (exit_code )
307
+ def use_map_file (input_file ):
308
+ """Check whether the input file needs to be replaced
309
+ because enableQnodeMap is enabled.
327
310
328
- for event_param in event_params_map :
329
- order_id = event_params_map [event_param ]["order_id" ]
330
- pseudo_file_name = event_params_map [event_param ]["order_id_map" ][order_id ]
331
- print (f"replacing event { event_param } with order_id { order_id } to: { pseudo_file_name } " )
332
- cmd_line = cmd_line .replace (event_param , pseudo_file_name )
333
- data_params = data_params .replace (event_param , pseudo_file_name )
311
+ Parameters
312
+ ----------
313
+ input_file : `str`
314
+ Input file either a pseudo file or job name.
334
315
335
- # If job name map is enabled, data_params will only contain order_id
336
- # information. Here we will convert order_id information to LSST pseudo
337
- # file names.
316
+ Returns
317
+ -------
318
+ use_qnode_map: `bool`
319
+ Whether qnode_map is used. There is a placeholder 'PH'
320
+ when enableQnodeMap is true.
321
+ """
322
+ parts = input_file .split (":" )
323
+ use_qnode_map = len (parts ) == 2 and parts [0 ] == "PH"
324
+ return use_qnode_map
325
+
326
+
327
+ if __name__ == "__main__" :
328
+ deliver_input_files (sys .argv [3 ], sys .argv [4 ], sys .argv [5 ])
329
+ cmd_line = str (binascii .unhexlify (sys .argv [1 ]).decode ())
330
+ data_params = sys .argv [2 ]
331
+ cmd_line = replace_environment_vars (cmd_line )
332
+
333
+ print (f"cmd_line: { cmd_line } " )
334
+ print (f"data_params: { data_params } " )
335
+
336
+ # If EventService is enabled, data_params will only contain
337
+ # event information. So we need to convert the event information
338
+ # to LSST pseudo file names. If EventService is not enabled,
339
+ # this part will not change data_params.
340
+ ret_rep = replace_event_file (data_params , sys .argv [4 ])
341
+ ret_event_status , with_events , with_order_id_map , event_params_map = ret_rep
342
+ print (
343
+ f"ret_event_status: { ret_event_status } , "
344
+ f"with_events: { with_events } "
345
+ f"with_order_id_map: { with_order_id_map } "
346
+ )
347
+ if not ret_event_status :
348
+ print ("failed to map EventService/orderIdMap parameters to original LSST pseudo file names" )
349
+ exit_code = 1
350
+ sys .exit (exit_code )
351
+
352
+ for event_param in event_params_map :
353
+ order_id = event_params_map [event_param ]["order_id" ]
354
+ pseudo_file_name = event_params_map [event_param ]["order_id_map" ][order_id ]
355
+ print (f"replacing event { event_param } with order_id { order_id } to: { pseudo_file_name } " )
356
+ cmd_line = cmd_line .replace (event_param , pseudo_file_name )
357
+ data_params = data_params .replace (event_param , pseudo_file_name )
358
+
359
+ # If job name map is enabled, data_params will only contain order_id
360
+ # information. Here we will convert order_id information to LSST pseudo
361
+ # file names.
362
+
363
+ data_params = data_params .split ("+" )
364
+
365
+ """Replace the pipetask command line placeholders
366
+ with actual data provided in the script call
367
+ in form placeholder1:file1+placeholder2:file2:...
368
+ """
369
+ cmd_line = replace_files_placeholders (cmd_line , sys .argv [4 ])
338
370
339
- data_params = data_params .split ("+" )
371
+ jobname = data_params [0 ]
372
+ if use_map_file (jobname ):
373
+ with open ("qnode_map.json" , encoding = "utf-8" ) as f :
374
+ qnode_map = json .load (f )
375
+ data_params = qnode_map [jobname ].split ("+" )
340
376
341
- """Replace the pipetask command line placeholders
342
- with actual data provided in the script call
343
- in form placeholder1:file1+placeholder2:file2:...
344
- """
345
- cmd_line = replace_files_placeholders (cmd_line , sys .argv [4 ])
346
-
347
- for key_value_pair in data_params [1 :]:
348
- (key , value ) = key_value_pair .split (":" )
349
- cmd_line = cmd_line .replace ("{" + key + "}" , value )
350
-
351
- print ("executable command line:" )
352
- print (cmd_line )
353
-
354
- exit_status = os .system (cmd_line )
355
- exit_code = 1
356
- if os .WIFSIGNALED (exit_status ):
357
- exit_code = os .WTERMSIG (exit_status ) + 128
358
- elif os .WIFEXITED (exit_status ):
359
- exit_code = os .WEXITSTATUS (exit_status )
360
- sys .exit (exit_code )
377
+ for key_value_pair in data_params [1 :]:
378
+ (key , value ) = key_value_pair .split (":" )
379
+ cmd_line = cmd_line .replace ("{" + key + "}" , value )
380
+
381
+ print ("executable command line:" )
382
+ print (cmd_line )
383
+
384
+ exit_status = os .system (cmd_line )
385
+ exit_code = 1
386
+ if os .WIFSIGNALED (exit_status ):
387
+ exit_code = os .WTERMSIG (exit_status ) + 128
388
+ elif os .WIFEXITED (exit_status ):
389
+ exit_code = os .WEXITSTATUS (exit_status )
390
+ sys .exit (exit_code )
0 commit comments