22from Configuration .PyReleaseValidation import WorkFlow
33import os ,time
44import shutil
5+ import re
56from subprocess import Popen
67from os .path import exists , basename , join
78from datetime import datetime
@@ -91,13 +92,15 @@ def closeCmd(i,ID):
9192 inFile = None
9293 lumiRangeFile = None
9394 aborted = False
95+ outputExtensionForStep = {}
9496 for (istepmone ,com ) in enumerate (self .wf .cmds ):
9597 # isInputOk is used to keep track of the das result. In case this
9698 # is False we use a different error message to indicate the failed
9799 # das query.
98100 isInputOk = True
99101 istep = istepmone + 1
100102 cmd = preamble
103+ outputExtensionForStep [istep ]= ''
101104 if aborted :
102105 self .npass .append (0 )
103106 self .nfail .append (0 )
@@ -182,13 +185,15 @@ def closeCmd(i,ID):
182185 # 134 is an existing workflow where harvesting has to operate on AlcaReco and NOT on DQM; hard-coded..
183186 if 'HARVESTING' in cmd and not 134 == self .wf .numId and not '--filein' in cmd :
184187 cmd += ' --filein file:step%d_inDQM.root --fileout file:step%d.root ' % (istep - 1 ,istep )
188+ outputExtensionForStep [istep ] = '.root'
185189 else :
186190 # Disable input for premix stage1 to allow combined stage1+stage2 workflow
187191 # Disable input for premix stage2 in FastSim to allow combined stage1+stage2 workflow (in FS, stage2 does also GEN)
188192 # Ugly hack but works
189193 extension = '.root'
190194 if '--rntuple_out' in cmd :
191195 extension = '.rntpl'
196+ outputExtensionForStep [istep ] = extension
192197 if istep != 1 and not '--filein' in cmd and not 'premix_stage1' in cmd and not ("--fast" in cmd and "premix_stage2" in cmd ):
193198 steps = cmd .split ("-s " )[1 ].split (" " )[0 ] ## relying on the syntax: cmsDriver -s STEPS --otherFlags
194199 if "ALCA" not in steps :
@@ -199,6 +204,19 @@ def closeCmd(i,ID):
199204 cmd += ' --filein %s' % (self .recoOutput )
200205 else :
201206 cmd += ' --filein file:step%s%s ' % (istep - 1 ,extension )
207+ elif istep != 1 and '--filein' in cmd and '--filetype' not in cmd :
208+ #make sure correct extension is being used
209+ #find the previous state index
210+ expression = '--filein\s+file:step([1-9])(_[a-zA-Z]+)*\.[a-z]+'
211+ m = re .search (expression , cmd )
212+ if m :
213+ cmd = re .sub (expression ,r'--filein file:step\1\2' + outputExtensionForStep [int (m .group (1 ))],cmd )
214+ elif extension == '.rntpl' :
215+ #some ALCA steps use special file names without step_ prefix and these are also force to use RNTuple
216+ expression = '--filein\s+file:([a-zA-Z0-9_]+)*\.[a-z]+'
217+ m = re .search (expression , cmd )
218+ if m :
219+ cmd = re .sub (expression ,r'--filein file:\1.rntpl' ,cmd )
202220 if not '--fileout' in com :
203221 cmd += ' --fileout file:step%s%s ' % (istep ,extension )
204222 if "RECO" in cmd :
0 commit comments