diff --git a/MC/bin/o2dpg_qc_finalization_workflow.py b/MC/bin/o2dpg_qc_finalization_workflow.py index 2a5f29449..d8a5c7d4e 100755 --- a/MC/bin/o2dpg_qc_finalization_workflow.py +++ b/MC/bin/o2dpg_qc_finalization_workflow.py @@ -14,6 +14,7 @@ import argparse from os import environ, mkdir from os.path import join, dirname, isdir +import re sys.path.append(join(dirname(__file__), '.', 'o2dpg_workflow_utils')) @@ -48,9 +49,17 @@ def add_QC_finalization(taskName, qcConfigPath, needs=None): needs = [taskName + '_local' + str(tf) for tf in range(1, ntimeframes + 1)] task = createTask(name=QC_finalize_name(taskName), needs=needs, cwd=qcdir, lab=["QC"], cpu=1, mem='2000') - task['cmd'] = f'o2-qc --config {qcConfigPath} --remote-batch {taskName}.root' + \ + def remove_json_prefix(path): + return re.sub(r'^json://', '', path) + + configFilePathOnDisk = remove_json_prefix(qcConfigPath) + # we check if the configFilePath actually exists in the currently loaded software. Otherwise we exit immediately and gracefully + task['cmd'] = ' if [ -f ' + configFilePathOnDisk + ' ]; then { ' + task['cmd'] += f'o2-qc --config {qcConfigPath} --remote-batch {taskName}.root' + \ f' --override-values "qc.config.database.host={qcdbHost};qc.config.Activity.number={run};qc.config.Activity.type=PHYSICS;qc.config.Activity.periodName={productionTag};qc.config.Activity.beamType={beamType};qc.config.conditionDB.url={conditionDB}"' + \ ' ' + getDPL_global_options() + task['cmd'] += ' ;} else { echo "Task ' + taskName + ' not performed due to config file not found "; } fi' + stages.append(task) ## Adds a postprocessing QC workflow diff --git a/MC/bin/o2dpg_sim_workflow.py b/MC/bin/o2dpg_sim_workflow.py index eb84df143..b559405f6 100755 --- a/MC/bin/o2dpg_sim_workflow.py +++ b/MC/bin/o2dpg_sim_workflow.py @@ -1337,11 +1337,21 @@ def getDigiTaskName(det): def addQCPerTF(taskName, needs, readerCommand, configFilePath, objectsFile=''): task = createTask(name=taskName + '_local' + str(tf), needs=needs, tf=tf, cwd=timeframeworkdir, lab=["QC"], cpu=1, mem='2000') objectsFile = objectsFile if len(objectsFile) > 0 else taskName + '.root' - # the --local-batch argument will make QC Tasks store their results in a file and merge with any existing objects - task['cmd'] = f'{readerCommand} | o2-qc --config {configFilePath}' + \ + + def remove_json_prefix(path): + return re.sub(r'^json://', '', path) + + configFilePathOnDisk = remove_json_prefix(configFilePath) + # we check if the configFilePath actually exists in the currently loaded software. Otherwise we exit immediately and gracefully + task['cmd'] = ' if [ -f ' + configFilePathOnDisk + ' ]; then { ' + # The actual QC command + # the --local-batch argument will make QC Tasks store their results in a file and merge with any existing objects + task['cmd'] += f'{readerCommand} | o2-qc --config {configFilePath}' + \ f' --local-batch ../{qcdir}/{objectsFile}' + \ f' --override-values "qc.config.database.host={args.qcdbHost};qc.config.Activity.number={args.run};qc.config.Activity.type=PHYSICS;qc.config.Activity.periodName={args.productionTag};qc.config.Activity.beamType={args.col};qc.config.Activity.start={args.timestamp};qc.config.conditionDB.url={args.conditionDB}"' + \ ' ' + getDPL_global_options(ccdbbackend=False) + task['cmd'] += ' ;} else { echo "Task ' + taskName + ' not performed due to config file not found "; } fi' + # Prevents this task from being run for multiple TimeFrames at the same time, thus trying to modify the same file. task['semaphore'] = objectsFile workflow['stages'].append(task)