3131# pass name
3232# --period-name PERIOD_NAME
3333# prodcution tag
34- # --config CONFIG overwrite thee default config JSON. Pass as json://< path/to/file>
34+ # --config CONFIG overwrite the default config JSON. Pass as </ path/to/file>, will be automatically configured to json://
3535# --only-analyses [ONLY_ANALYSES [ONLY_ANALYSES ...]]
3636# filter only on these analyses
3737# --merged-task add merged analysis task (one pipe for all) with name "MergedAnalyses"
6767import importlib .util
6868import argparse
6969from os import environ , makedirs
70- from os .path import join , exists , abspath , expanduser
70+ from os .path import join , exists , abspath , expanduser , normpath
7171
7272# make sure O2DPG + O2 is loaded
7373O2DPG_ROOT = environ .get ('O2DPG_ROOT' )
9595ANALYSIS_VALID_MC = "mc"
9696ANALYSIS_VALID_DATA = "data"
9797
98- ANALYSIS_CONFIGS = {ANALYSIS_VALID_MC : "json:// ${O2DPG_ROOT}/MC/config/analysis_testing/json/analysis-testing-mc.json" ,
99- ANALYSIS_VALID_DATA : "json:// ${O2DPG_ROOT}/MC/config/analysis_testing/json/analysis-testing-data.json" }
98+ ANALYSIS_CONFIGS = {ANALYSIS_VALID_MC : "${O2DPG_ROOT}/MC/config/analysis_testing/json/analysis-testing-mc.json" ,
99+ ANALYSIS_VALID_DATA : "${O2DPG_ROOT}/MC/config/analysis_testing/json/analysis-testing-data.json" }
100100
101101# collect all analyses
102102ANALYSES = []
114114analysis_EventTrackQA = {"name" : "EventTrackQA" ,
115115 "expected_output" : ["AnalysisResults.root" ],
116116 "valid_for" : [ANALYSIS_VALID_MC , ANALYSIS_VALID_DATA ],
117- "cmd" : "o2-analysis-timestamp {CONFIG} | o2-analysis-track-propagation {CONFIG} | o2-analysis-trackselection {CONFIG} | o2-analysis-event-selection {CONFIG} | o2-analysis-pid-tof-base {CONFIG} | o2-analysis-qa-event-track {CONFIG} {AOD}" }
117+ "cmd" : ["o2-analysis-timestamp" ,
118+ "o2-analysis-track-propagation" ,
119+ "o2-analysis-trackselection" ,
120+ "o2-analysis-multiplicity-table" ,
121+ "o2-analysis-event-selection" ,
122+ "o2-analysis-qa-event-track" ]}
118123ANALYSES .append (analysis_EventTrackQA )
119124analysis_K0STrackingEfficiencyQA = {"name" : "K0STrackingEfficiencyQA" ,
120125 "expected_output" : ["AnalysisResults.root" ],
@@ -325,9 +330,17 @@ def add_analysis_tasks(workflow, input_aod="./AO2D.root", output_dir="./Analysis
325330 input_aod = f"@{ input_aod } "
326331 data_or_mc = ANALYSIS_VALID_MC if is_mc else ANALYSIS_VALID_DATA
327332 configuration = ANALYSIS_CONFIGS [data_or_mc ] if config is None else config
333+ configuration = configuration .replace ("json://" , "" )
334+ configuration = abspath (normpath (configuration ))
335+ configuration = f"json://{ configuration } "
328336 for ana in ANALYSES :
329- if data_or_mc in ana ["valid_for" ] and (not analyses_only or (ana ["name" ] in analyses_only )):
330- workflow .append (create_ana_task (ana ["name" ], ana ["cmd" ].format (CONFIG = f"--configuration { configuration } " , AOD = f"--aod-file { input_aod } " ), output_dir , needs = needs , is_mc = is_mc ))
337+ if data_or_mc in ana ["valid_for" ] and (not analyses_only or (ana ["name" ] in analyses_only )):
338+ if type (ana ["cmd" ]) is list :
339+ piped_analysis = f" --configuration { configuration } | " .join (ana ["cmd" ])
340+ piped_analysis += f" --configuration { configuration } --aod-file { input_aod } "
341+ workflow .append (create_ana_task (ana ["name" ], piped_analysis , output_dir , needs = needs , is_mc = is_mc ))
342+ else :
343+ workflow .append (create_ana_task (ana ["name" ], ana ["cmd" ].format (CONFIG = f"--configuration { configuration } " , AOD = f"--aod-file { input_aod } " ), output_dir , needs = needs , is_mc = is_mc ))
331344 continue
332345 print (f"Analysis { ana ['name' ]} not added since not compatible with isMC={ is_mc } and filetred analyses { analyses_only } " )
333346 if add_merged_task :
@@ -400,7 +413,7 @@ def run(args):
400413
401414def main ():
402415 """entry point when run directly from command line"""
403- parser = argparse .ArgumentParser (description = 'Create analysi test workflow' )
416+ parser = argparse .ArgumentParser (description = 'Create analysis test workflow' )
404417 parser .add_argument ("-f" , "--input-file" , dest = "input_file" , default = "./AO2D.root" , help = "full path to the AO2D input" , required = True )
405418 parser .add_argument ("-a" , "--analysis-dir" , dest = "analysis_dir" , default = "./Analysis" , help = "the analysis output and working directory" )
406419 parser .add_argument ("-o" , "--output" , default = "workflow_analysis_test.json" , help = "the workflow file name" )
@@ -409,7 +422,7 @@ def main():
409422 parser .add_argument ("--run-number" , dest = "run_number" , type = int , default = 300000 , help = "the run number" )
410423 parser .add_argument ("--pass-name" , dest = "pass_name" , help = "pass name" )
411424 parser .add_argument ("--period-name" , dest = "period_name" , help = "period name" )
412- parser .add_argument ("--config" , help = "overwrite the default config JSON. Pass as json:// </path/to/file>" )
425+ parser .add_argument ("--config" , help = "overwrite the default config JSON. Pass as </path/to/file>, will be automatically configured to json:// " )
413426 parser .add_argument ("--only-analyses" , dest = "only_analyses" , nargs = "*" , help = "filter only on these analyses" )
414427 parser .add_argument ("--merged-task" , dest = "merged_task" , action = "store_true" , help = "add merged analysis task (one pipe for all) with name \" MergedAnalyses\" " )
415428 parser .set_defaults (func = run )
0 commit comments