Skip to content

Commit 495c31b

Browse files
committed
QC Workflow: Add option to set merged QC JSON cache filename from gen_topo
1 parent 86264a1 commit 495c31b

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

DATA/production/qc-workflow.sh

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ if [[ -z "$WORKFLOW" ]] || [[ -z "$MYDIR" ]]; then
55
exit 1
66
fi
77

8-
if [[ -z $QC_JSON_FROM_OUTSIDE ]]; then
8+
if [[ -z $QC_JSON_FROM_OUTSIDE && ! -z $GEN_TOPO_QC_JSON_FILE && -f $GEN_TOPO_QC_JSON_FILE ]]; then
9+
QC_JSON_FROM_OUTSIDE=$GEN_TOPO_QC_JSON_FILE
10+
elif [[ -z $QC_JSON_FROM_OUTSIDE ]]; then
911
if [[ $EPNSYNCMODE == 1 || "0$GEN_TOPO_LOAD_QC_JSON_FROM_CONSUL" == "01" ]]; then
1012
[[ -z "$QC_JSON_TPC" ]] && QC_JSON_TPC=consul://o2/components/qc/ANY/any/tpc-full-qcmn
1113
[[ -z "$QC_JSON_ITS" ]] && QC_JSON_ITS=consul://o2/components/qc/ANY/any/its-qcmn-epn-full
@@ -137,11 +139,15 @@ if [[ -z $QC_JSON_FROM_OUTSIDE ]]; then
137139
fi
138140

139141
if [[ ! -z "$JSON_FILES" ]]; then
140-
mkdir -p $GEN_TOPO_WORKDIR/json_cache
141-
if [[ "0$GEN_TOPO_ONTHEFLY" == "01" ]]; then
142-
find $GEN_TOPO_WORKDIR/json_cache/ -maxdepth 1 -type f -mtime +30 | xargs rm -f
142+
if [[ -z "$GEN_TOPO_QC_JSON_FILE" ]]; then
143+
mkdir -p $GEN_TOPO_WORKDIR/json_cache
144+
if [[ "0$GEN_TOPO_ONTHEFLY" == "01" ]]; then
145+
find $GEN_TOPO_WORKDIR/json_cache/ -maxdepth 1 -type f -mtime +30 | xargs rm -f
146+
fi
147+
MERGED_JSON_FILENAME=$GEN_TOPO_WORKDIR/json_cache/`date +%Y%m%d-%H%M%S`-$$-$RANDOM-$OUTPUT_SUFFIX.json
148+
else
149+
MERGED_JSON_FILENAME=$GEN_TOPO_QC_JSON_FILE
143150
fi
144-
MERGED_JSON_FILENAME=$GEN_TOPO_WORKDIR/json_cache/`date +%Y%m%d-%H%M%S`-$$-$RANDOM-$OUTPUT_SUFFIX.json
145151
jq -n 'reduce inputs as $s (input; .qc.tasks += ($s.qc.tasks) | .qc.checks += ($s.qc.checks) | .qc.externalTasks += ($s.qc.externalTasks) | .qc.postprocessing += ($s.qc.postprocessing)| .dataSamplingPolicies += ($s.dataSamplingPolicies))' $QC_JSON_GLOBAL $JSON_FILES > $MERGED_JSON_FILENAME
146152
if [[ $? != 0 ]]; then
147153
echo Merging QC workflow with JSON files $JSON_FILES failed 1>&2

DATA/tools/parse

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ for line in f:
9090
print('O2 not loaded')
9191
raise
9292
xml_postprocessing = ('GEN_TOPO_OOM_WORKAROUND' in os.environ and int(os.environ['GEN_TOPO_OOM_WORKAROUND'])) or ('GEN_TOPO_DDS_ASSETS' in os.environ and int(os.environ['GEN_TOPO_DDS_ASSETS']))
93+
if xml_postprocessing:
94+
json_cache_path = os.environ['GEN_TOPO_WORKDIR'] + '/json_cache'
95+
if not os.path.exists(json_cache_path):
96+
os.makedirs(json_cache_path, 0o770)
97+
os.environ['GEN_TOPO_QC_JSON_FILE'] = json_cache_path + '/qc_tmp_' + datetime.datetime.now().strftime('%y-%m-%d-%H-%M-%S') + '_' + str(random.randrange(100000000)) + '.json'
9398
with tempfile.TemporaryDirectory(prefix='o2_workflow_') as tmpdir:
9499
if 'GEN_TOPO_OVERRIDE_TEMPDIR' in os.environ:
95100
tmpdir = os.environ['GEN_TOPO_OVERRIDE_TEMPDIR']
@@ -123,13 +128,10 @@ for line in f:
123128
command_log_filter = '"^\[INFO"'
124129
command_preopt = 'GEN_TOPO_CALIB_WORKFLOW=' + str(is_calib_workflow)
125130
if xml_postprocessing:
126-
json_cache_path = os.environ['GEN_TOPO_WORKDIR'] + '/json_cache'
127131
filename_xml = filename
128132
if not 'GEN_TOPO_WORKDIR' in os.environ:
129133
print('$GEN_TOPO_WORKDIR not set')
130134
raise
131-
if not os.path.exists(json_cache_path):
132-
os.makedirs(json_cache_path, 0o770)
133135
filename = json_cache_path + '/dpl_tmp_' + datetime.datetime.now().strftime('%y-%m-%d-%H-%M-%S') + wf[0] + str(i) + '_' + str(random.randrange(100000000)) + '.json'
134136
command_preopt += ' WORKFLOWMODE=dump'
135137
command = command_preopt + ' GLOBALDPLOPT+=" -b --dds-workflow-suffix _' + wf[0] + str(i) + '" ' + wf[3] + ' | grep -v ' + command_log_filter + ' > ' + filename + ' && [ `grep "^\[" ' + filename + ' | wc -l` == 0 ]'

0 commit comments

Comments
 (0)