Skip to content

Commit 2e5d074

Browse files
committed
MC-QC stability fix
QC tasks are now only executed at runtime *if* the mentioned qc-config file is actually found. This prevents crashes/errors that we have seen when this was not the case. In practice the situation may arise if the workflow is constructed with a different O2DPG tag than the executing software environment (2-tag mechanism for MC).
1 parent 6f985de commit 2e5d074

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

MC/bin/o2dpg_qc_finalization_workflow.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import argparse
1515
from os import environ, mkdir
1616
from os.path import join, dirname, isdir
17+
import re
1718

1819
sys.path.append(join(dirname(__file__), '.', 'o2dpg_workflow_utils'))
1920

@@ -48,9 +49,17 @@ def add_QC_finalization(taskName, qcConfigPath, needs=None):
4849
needs = [taskName + '_local' + str(tf) for tf in range(1, ntimeframes + 1)]
4950

5051
task = createTask(name=QC_finalize_name(taskName), needs=needs, cwd=qcdir, lab=["QC"], cpu=1, mem='2000')
51-
task['cmd'] = f'o2-qc --config {qcConfigPath} --remote-batch {taskName}.root' + \
52+
def remove_json_prefix(path):
53+
return re.sub(r'^json://', '', path)
54+
55+
configFilePathOnDisk = remove_json_prefix(qcConfigPath)
56+
# we check if the configFilePath actually exists in the currently loaded software. Otherwise we exit immediately and gracefully
57+
task['cmd'] = ' if [ -f ' + configFilePathOnDisk + ' ]; then { '
58+
task['cmd'] += f'o2-qc --config {qcConfigPath} --remote-batch {taskName}.root' + \
5259
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}"' + \
5360
' ' + getDPL_global_options()
61+
task['cmd'] += ' ;} else { echo "Task ' + taskName + ' not performed due to config file not found "; } fi'
62+
5463
stages.append(task)
5564

5665
## Adds a postprocessing QC workflow

MC/bin/o2dpg_sim_workflow.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,11 +1337,21 @@ def getDigiTaskName(det):
13371337
def addQCPerTF(taskName, needs, readerCommand, configFilePath, objectsFile=''):
13381338
task = createTask(name=taskName + '_local' + str(tf), needs=needs, tf=tf, cwd=timeframeworkdir, lab=["QC"], cpu=1, mem='2000')
13391339
objectsFile = objectsFile if len(objectsFile) > 0 else taskName + '.root'
1340-
# the --local-batch argument will make QC Tasks store their results in a file and merge with any existing objects
1341-
task['cmd'] = f'{readerCommand} | o2-qc --config {configFilePath}' + \
1340+
1341+
def remove_json_prefix(path):
1342+
return re.sub(r'^json://', '', path)
1343+
1344+
configFilePathOnDisk = remove_json_prefix(configFilePath)
1345+
# we check if the configFilePath actually exists in the currently loaded software. Otherwise we exit immediately and gracefully
1346+
task['cmd'] = ' if [ -f ' + configFilePathOnDisk + ' ]; then { '
1347+
# The actual QC command
1348+
# the --local-batch argument will make QC Tasks store their results in a file and merge with any existing objects
1349+
task['cmd'] += f'{readerCommand} | o2-qc --config {configFilePath}' + \
13421350
f' --local-batch ../{qcdir}/{objectsFile}' + \
13431351
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}"' + \
13441352
' ' + getDPL_global_options(ccdbbackend=False)
1353+
task['cmd'] += ' ;} else { echo "Task ' + taskName + ' not performed due to config file not found "; } fi'
1354+
13451355
# Prevents this task from being run for multiple TimeFrames at the same time, thus trying to modify the same file.
13461356
task['semaphore'] = objectsFile
13471357
workflow['stages'].append(task)

0 commit comments

Comments
 (0)