4 from Configuration.PyReleaseValidation.WorkFlow
import WorkFlow
43 'relval_highstats':
'hi-' ,
44 'relval_pileup':
'PU-' ,
45 'relval_generator':
'gen-' ,
46 'relval_production':
'prod-' ,
48 'relval_upgrade':
'upg-',
49 'relval_identity':
'id-',
50 'relval_machine':
'mach-'
53 self.
files = [
'relval_standard' ,
73 for k,v
in step.items():
74 if 'no_exec' in k :
continue
75 if k.lower() ==
'cfg':
78 if k.lower() ==
'input':
85 cmd +=
' ' + k +
' ' + str(v)
86 return cfg, input, cmd
88 def readMatrix(self, fileNameIn, useInput=None, refRel=None, fromScratch=None):
92 print "processing ", fileNameIn
95 _tmpMod = __import__(
'Configuration.PyReleaseValidation.'+fileNameIn )
96 self.
relvalModule = sys.modules[
'Configuration.PyReleaseValidation.'+fileNameIn]
98 print "ERROR importing file ", fileNameIn, str(e)
101 print "request for INPUT for ", useInput
111 for k
in self.relvalModule.workflows.keys():
112 fromInput[float(k)]=int(il)
114 fromInput[float(ik)]=int(il)
117 for k
in self.relvalModule.workflows.keys():
118 fromInput[float(k)]=0
120 fromInput[float(i)]=0
123 fromScratch=
map(float,fromScratch)
124 for num
in fromScratch:
130 self.relvalModule.steps.overwrite(p)
135 refRels=refRel.split(
',')
136 if len(refRels)!=len(self.relvalModule.baseDataSetRelease):
138 self.relvalModule.changeRefRelease(
139 self.relvalModule.steps,
140 zip(self.relvalModule.baseDataSetRelease,refRels)
143 self.relvalModule.changeRefRelease(
144 self.relvalModule.steps,
145 [(x,refRel)
for x
in self.relvalModule.baseDataSetRelease]
149 for num, wfInfo
in self.relvalModule.workflows.items():
154 if wfName.strip() ==
'': wfName = stepList[0]
160 if not type(addCom)==list: addCom=[addCom]
165 while len(addTo)!=len(stepList):
174 ilevel=fromInput[num]
176 for (stepIr,step)
in enumerate(reversed(stepList)):
178 stepI=(len(stepList)-stepIr)-1
184 testName=
'__'.
join(stepList[0:stepI+1])+
'INPUT'
186 testName=step+
'INPUT'
188 if testName
in self.relvalModule.steps.keys():
190 stepList[stepI]=testName
193 for p
in range(stepI):
199 for (stepI,step)
in enumerate(stepList):
205 'RECODFROMRAWRECO',
'SKIMD',
'SKIMCOSD',
'SKIMDreHLT'
211 if len(name) > 0 : name +=
'+'
216 if step+'INPUT' in self.relvalModule.steps.keys():
217 stepName = step+"INPUT"
218 stepList.remove(step)
219 stepList.insert(stepIndex,stepName)
223 if addCom
and (
not addTo
or addTo[stepIndex]==1):
225 copyStep=
merge(addCom+[self.relvalModule.steps[stepName]])
226 cfg, input, opts = self.
makeCmd(copyStep)
228 cfg, input, opts = self.
makeCmd(self.relvalModule.steps[stepName])
231 msg =
"FATAL ERROR: found both cfg and input for workflow "+str(num)+
' step '+stepName
240 cmd =
'cmsDriver.py '+cfg+
' '+opts
242 cmd =
'cmsDriver.py step'+str(stepIndex+1)+
' '+opts
244 cmd+=
' --io %s.io --python %s.py'%(stepName,stepName)
247 if stepIndex
in self.
apply or stepName
in self.
apply:
252 cmd=cmd.replace(
'DQMIO',
'DQM')
253 cmd=cmd.replace(
'--filetype DQM',
'')
255 ranStepList.append(stepName)
258 self.
workFlowSteps[(num,prefix)] = (num, name, commands, ranStepList)
263 def showRaw(self, useInput, refRel=None, fromScratch=None, what='all',step1Only=False,selected=None):
266 selected=
map(float,selected)
267 for matrixFile
in self.
files:
271 if self.
what !=
'all' and self.
what not in matrixFile:
272 print "ignoring non-requested file",matrixFile
276 self.
readMatrix(matrixFile, useInput, refRel, fromScratch)
278 print "ERROR reading file:", matrixFile, str(e)
283 dataFileName = matrixFile.replace(
'relval_',
'cmsDriver_')+
'_hlt.txt'
284 outFile = open(dataFileName,
'w')
286 print "found ", len(self.workFlowSteps.keys()),
' workflows for ', dataFileName
287 ids = self.workFlowSteps.keys()
293 if selected
and not (key[0]
in selected):
296 if key[0]==203.1
or key[0]==204.1
or key[0]==205.1
or key[0]==4.51
or key[0]==4.52:
continue
299 wfName,stepNames= name.split(
'+',1)
301 stepNames=stepNames.replace(
'+RECODFROMRAWRECO',
'')
302 stepNames=stepNames.replace(
'+SKIMCOSD',
'')
303 stepNames=stepNames.replace(
'+SKIMD',
'')
304 if 'HARVEST' in stepNames:
306 exactb=stepNames.index(
'+HARVEST')
307 exacte=stepNames.index(
'+',exactb+1)
if (
'+' in stepNames[exactb+1:])
else (len(stepNames))
308 stepNames=stepNames.replace(stepNames[exactb:exacte],
'')
311 step1,otherSteps = stepNames.split(
'+',1)
313 line = str(num) +
' ++ '+ wfName
314 if otherSteps
and not step1Only:
315 line +=
' ++ ' +otherSteps.replace(
'+',
',')
319 if not isinstance(commands[0],str):
320 inputInfo=commands[0]
322 for (i,c)
in enumerate(otherSteps.split(
'+')):
324 for p
in range(len(indexAndSteps),i+2):
325 indexAndSteps.append(set())
326 indexAndSteps[i+1].
add((c,commands[i+1]))
330 if step1Only:
continue
331 line +=
' ++ REALDATA: '+inputInfo.dataSet
332 if inputInfo.run!=[]: line +=
', RUN:'+
'|'.
join(
map(str,inputInfo.run))
333 line +=
', FILES: ' +str(inputInfo.files)
334 line +=
', EVENTS: '+str(inputInfo.events)
335 if inputInfo.label!=
'':
336 line +=
', LABEL: ' +inputInfo.label
337 line +=
', LOCATION:'+inputInfo.location
340 line +=
' @@@ '+commands[0]
342 line=line.replace(
'DQMIO',
'DQM')
344 outFile.write(line+
'\n')
347 outFile.write(
'\n'+
'\n')
348 if step1Only:
continue
350 for (index,s)
in enumerate(indexAndSteps):
351 for (stepName,cmd)
in s:
353 if 'dasquery.log' in cmd:
continue
354 line =
'STEP%d ++ '%(stepIndex,) +stepName +
' @@@ '+cmd
356 line=line.replace(
'DQMIO',
'DQM')
357 outFile.write(line+
'\n')
358 outFile.write(
'\n'+
'\n')
360 print "wrote ",writtenWF,
' workflow'+(
's' if (writtenWF!=1)
else ''),
' to ', outFile.name
365 if selected: selected =
map(float,selected)
367 fmt1 =
"%-6s %-35s [1]: %s ..."
368 fmt2 =
" %35s [%d]: %s ..."
369 print "\nfound a total of ", len(self.
workFlows),
' workflows:'
371 print " of which the following", len(selected),
'were selected:'
374 fmt1 =
"%-6s %-35s [1]: %s "
375 fmt2 =
" %35s [%d]: %s"
379 if selected
and float(wf.numId)
not in selected:
continue
380 if extended:
print ''
382 for i
in range(len(N),len(wf.cmds)): N.append(0)
384 wfName, stepNames = wf.nameId.split(
'+',1)
385 for i,s
in enumerate(wf.cmds):
388 print fmt1 % (wf.numId, stepNames, (str(s)+
' ')[:maxLen])
390 print fmt2 % (
' ', i+1, (str(s)+
' ')[:maxLen])
392 print "%-6s %-35s "% (wf.numId, stepNames)
395 for i,n
in enumerate(N):
396 if n:
print n,
'workflows with',i+1,
'steps'
405 keyList = self.workFlowSteps.keys()
409 if pref != prefixIn :
continue
414 num, name, commands, stepList = val
415 nameId = str(num)+
'_'+name
417 print "==> duplicate name found for ", nameId
418 print ' keeping : ', self.
nameList[nameId]
419 print ' ignoring : ', val
423 self.workFlows.append(
WorkFlow(num, name, commands=commands))
427 def prepare(self, useInput=None, refRel='', fromScratch=None):
429 for matrixFile
in self.
files:
430 if self.
what !=
'all' and self.
what not in matrixFile:
431 print "ignoring non-requested file",matrixFile
433 if self.
what ==
'all' and (
'upgrade' in matrixFile):
434 print "ignoring",matrixFile,
"from default matrix"
438 self.
readMatrix(matrixFile, useInput, refRel, fromScratch)
440 print "ERROR reading file:", matrixFile, str(e)
446 print "ERROR creating workflows :", str(e)
450 def show(self, selected=None, extended=True):
453 print '\n',
'-'*80,
'\n'
459 pickle.dump(self.
workFlows, open(
'theMatrix.pkl',
'w') )
revertDqmio
maybe we want too level deep input
void add(const std::vector< const T * > &source, std::vector< const T * > &dest)
static std::string join(char **cmd)