Skip to content

Commit 9bd3ef2

Browse files
committed
Workflow parser: distribute QC JSON file as DDS asset
1 parent fb9ef60 commit 9bd3ef2

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

DATA/tools/parse

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ for line in f:
9494
json_cache_path = os.environ['GEN_TOPO_WORKDIR'] + '/json_cache'
9595
if not os.path.exists(json_cache_path):
9696
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'
97+
os.environ['GEN_TOPO_QC_JSON_FILE'] = os.path.abspath(json_cache_path + '/qc_tmp_' + datetime.datetime.now().strftime('%y-%m-%d-%H-%M-%S') + '_' + str(random.randrange(100000000)) + '.json')
9898
with tempfile.TemporaryDirectory(prefix='o2_workflow_') as tmpdir:
9999
if 'GEN_TOPO_OVERRIDE_TEMPDIR' in os.environ:
100100
tmpdir = os.environ['GEN_TOPO_OVERRIDE_TEMPDIR']
@@ -156,16 +156,16 @@ for line in f:
156156
command = 'sed -i \'s,^\( *<exe reachable="true">\).*\(|[^|]*</exe>\)$,\\1 cat ' + filename + ' \\2,\' ' + filename_xml
157157
if 'GEN_TOPO_DDS_ASSETS' in os.environ and int(os.environ['GEN_TOPO_DDS_ASSETS']):
158158
command = 'sed -i \'s/&/\&amp;/g; s/</\&lt;/g; s/>/\&gt;/g; s/"/\&quot;/g; s/\'"\'"\'/\&#39;/g\' ' + filename
159-
print('Running SED command', command)
159+
print('Running SED command for DPL JSON XML Escaping', command)
160160
if os.system(command) != 0:
161161
print('Error running sed on JSON file')
162162
asset_name = 'dpl_json_' + wf[0] + '_' + str(i)
163163
command = 'sed -i ' + \
164164
'-e \'s,^\( *<exe reachable="true">\).*\(|[^|]*</exe>\)$,\\1 cat ${DDS_LOCATION}/' + asset_name + '.asset \\2,\' ' + \
165-
'-e \'/^\( *<decltask name.*>$\)/a <assets><name>' + asset_name + '</name></assets>\' ' + \
166-
'-e \'/^\( *<topology name.*>$\)/a <asset name="' + asset_name + '" type="inline" visibility="global" value="\' ' + \
167-
'-e \'/^\( *<topology name.*>$\)/r ' + filename + '\' ' + \
168-
'-e \'/^\( *<topology name.*>$\)/a " />\' ' + \
165+
'-e \'/^ *<decltask name.*>$/a <assets><name>' + asset_name + '</name></assets>\' ' + \
166+
'-e \'/^ *<topology name.*>$/a <asset name="' + asset_name + '" type="inline" visibility="global" value="\' ' + \
167+
'-e \'/^ *<topology name.*>$/r ' + filename + '\' ' + \
168+
'-e \'/^ *<topology name.*>$/a " />\' ' + \
169169
filename_xml
170170
print('Running SED command', command)
171171
if os.system(command) != 0:
@@ -212,6 +212,21 @@ for line in f:
212212
if os.system(odccommand) != 0:
213213
print('\nError running odc: ', odccommand)
214214
raise
215+
if 'GEN_TOPO_DDS_ASSETS' in os.environ and int(os.environ['GEN_TOPO_DDS_ASSETS']) and os.path.exists(os.environ['GEN_TOPO_QC_JSON_FILE']):
216+
command = 'sed -i \'s/&/\&amp;/g; s/</\&lt;/g; s/>/\&gt;/g; s/"/\&quot;/g; s/\'"\'"\'/\&#39;/g\' ' + os.environ['GEN_TOPO_QC_JSON_FILE']
217+
print('Running SED command for DPL JSON XML Escaping', command)
218+
if os.system(command) != 0:
219+
print('Error running sed on JSON file')
220+
command = 'sed -i ' + \
221+
'-e \'s,' + os.environ['GEN_TOPO_QC_JSON_FILE'] + ',${DDS_LOCATION}/qc.json.asset,\' ' + \
222+
'-e \'/^ *<exe reachable="true">.*o2-qc --id.*qc.json.asset.*<\/exe>$/a <assets><name>qc.json</name></assets>\' ' + \
223+
'-e \'/^ *<topology name.*>$/a <asset name="qc.json" type="inline" visibility="global" value="\' ' + \
224+
'-e \'/^ *<topology name.*>$/r ' + os.environ['GEN_TOPO_QC_JSON_FILE'] + '\' ' + \
225+
'-e \'/^ *<topology name.*>$/a " />\' ' + \
226+
sys.argv[3]
227+
print('Running final SED command for QC JSONs', command)
228+
if os.system(command) != 0:
229+
print('Error running sed')
215230
else:
216231
outf = open(sys.argv[3], 'w+')
217232
for i in recoworkflows:

0 commit comments

Comments
 (0)