3 from Configuration.PyReleaseValidation.WorkFlow
import WorkFlow
4 from Configuration.PyReleaseValidation.MatrixUtil
import InputInfo
43 'relval_highstats':
'hi-' ,
44 'relval_pileup':
'PU-' ,
45 'relval_generator':
'gen-',
46 'relval_extendedgen':
'genExt-',
47 'relval_production':
'prod-' ,
49 'relval_upgrade':
'upg-',
50 'relval_identity':
'id-',
51 'relval_machine':
'mach-',
52 'relval_unsch':
'unsch-',
53 'relval_premix':
'premix-',
54 'relval_miniaod':
'miniaod-'
57 self.
files = [
'relval_standard' ,
72 'relval_highstats':
True ,
74 'relval_generator':
True,
75 'relval_extendedgen':
True,
76 'relval_production':
True,
78 'relval_upgrade':
False,
79 'relval_identity':
False,
80 'relval_machine':
True,
95 for k,v
in step.items():
96 if 'no_exec' in k :
continue
97 if k.lower() ==
'cfg':
100 if k.lower() ==
'input':
107 cmd +=
' ' + k +
' ' + str(v)
108 return cfg, input, cmd
112 if len(overrides.keys()) > 0:
113 copyStep=
merge([overrides]+[step])
118 def readMatrix(self, fileNameIn, useInput=None, refRel=None, fromScratch=None):
122 print "processing", fileNameIn
125 _tmpMod = __import__(
'Configuration.PyReleaseValidation.'+fileNameIn )
126 self.
relvalModule = sys.modules[
'Configuration.PyReleaseValidation.'+fileNameIn]
128 print "ERROR importing file ", fileNameIn, str(e)
131 if useInput
is not None:
132 print "request for INPUT for ", useInput
142 for k
in self.relvalModule.workflows.keys():
143 fromInput[float(k)]=int(il)
145 fromInput[float(ik)]=int(il)
148 for k
in self.relvalModule.workflows.keys():
149 fromInput[float(k)]=0
151 fromInput[float(i)]=0
154 fromScratch=
map(float,fromScratch)
155 for num
in fromScratch:
161 self.relvalModule.steps.overwrite(p)
166 refRels=refRel.split(
',')
167 if len(refRels)!=len(self.relvalModule.baseDataSetRelease):
169 self.relvalModule.changeRefRelease(
170 self.relvalModule.steps,
171 zip(self.relvalModule.baseDataSetRelease,refRels)
174 self.relvalModule.changeRefRelease(
175 self.relvalModule.steps,
176 [(x,refRel)
for x
in self.relvalModule.baseDataSetRelease]
180 for num, wfInfo
in self.relvalModule.workflows.items():
184 stepOverrides=wfInfo.overrides
186 if wfName.strip() ==
'': wfName = stepList[0]
192 if not type(addCom)==list: addCom=[addCom]
197 while len(addTo)!=len(stepList):
206 ilevel=fromInput[num]
208 for (stepIr,step)
in enumerate(reversed(stepList)):
210 stepI=(len(stepList)-stepIr)-1
216 testName=
'__'.
join(stepList[0:stepI+1])+
'INPUT'
218 testName=step+
'INPUT'
220 if testName
in self.relvalModule.steps.keys():
222 stepList[stepI]=testName
225 for p
in range(stepI):
231 for (stepI,step)
in enumerate(stepList):
237 'RECODFROMRAWRECO',
'SKIMD',
'SKIMCOSD',
'SKIMDreHLT'
243 if len(name) > 0 : name +=
'+'
248 if step+'INPUT' in self.relvalModule.steps.keys():
249 stepName = step+"INPUT"
250 stepList.remove(step)
251 stepList.insert(stepIndex,stepName)
254 if addCom
and (
not addTo
or addTo[stepIndex]==1):
256 copyStep=
merge(addCom+[self.
makeStep(self.relvalModule.steps[stepName],stepOverrides)])
257 cfg, input, opts = self.
makeCmd(copyStep)
259 cfg, input, opts = self.
makeCmd(self.
makeStep(self.relvalModule.steps[stepName],stepOverrides))
262 msg =
"FATAL ERROR: found both cfg and input for workflow "+str(num)+
' step '+stepName
271 cmd =
'cmsDriver.py '+cfg+
' '+opts
273 cmd =
'cmsDriver.py step'+str(stepIndex+1)+
' '+opts
275 cmd+=
' --io %s.io --python %s.py'%(stepName,stepName)
278 if stepIndex
in self.
apply or stepName
in self.
apply:
283 cmd=cmd.replace(
'DQMIO',
'DQM')
284 cmd=cmd.replace(
'--filetype DQM',
'')
286 ranStepList.append(stepName)
289 self.
workFlowSteps[(num,prefix)] = (num, name, commands, ranStepList)
294 def showRaw(self, useInput, refRel=None, fromScratch=None, what='all',step1Only=False,selected=None):
297 selected=
map(float,selected)
298 for matrixFile
in self.
files:
302 if self.
what !=
'all' and self.
what not in matrixFile:
303 print "ignoring non-requested file",matrixFile
307 print "ignoring file not used by default (enable with -w)",matrixFile
311 self.
readMatrix(matrixFile, useInput, refRel, fromScratch)
313 print "ERROR reading file:", matrixFile, str(e)
318 dataFileName = matrixFile.replace(
'relval_',
'cmsDriver_')+
'_hlt.txt'
319 outFile = open(dataFileName,
'w')
321 print "found ", len(self.workFlowSteps.keys()),
' workflows for ', dataFileName
322 ids = self.workFlowSteps.keys()
328 if selected
and not (key[0]
in selected):
331 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
334 wfName,stepNames= name.split(
'+',1)
336 stepNames=stepNames.replace(
'+RECODFROMRAWRECO',
'')
337 stepNames=stepNames.replace(
'+SKIMCOSD',
'')
338 stepNames=stepNames.replace(
'+SKIMD',
'')
339 if 'HARVEST' in stepNames:
341 exactb=stepNames.index(
'+HARVEST')
342 exacte=stepNames.index(
'+',exactb+1)
if (
'+' in stepNames[exactb+1:])
else (len(stepNames))
343 stepNames=stepNames.replace(stepNames[exactb:exacte],
'')
346 step1,otherSteps = stepNames.split(
'+',1)
348 line = str(num) +
' ++ '+ wfName
349 if otherSteps
and not step1Only:
350 line +=
' ++ ' +otherSteps.replace(
'+',
',')
354 if not isinstance(commands[0],str):
355 inputInfo=commands[0]
357 for (i,c)
in enumerate(otherSteps.split(
'+')):
359 for p
in range(len(indexAndSteps),i+2):
360 indexAndSteps.append(set())
361 indexAndSteps[i+1].
add((c,commands[i+1]))
365 if step1Only:
continue
366 line +=
' ++ REALDATA: '+inputInfo.dataSet
367 if inputInfo.run!=[]: line +=
', RUN:'+
'|'.
join(
map(str,inputInfo.run))
368 line +=
', FILES: ' +str(inputInfo.files)
369 line +=
', EVENTS: '+str(inputInfo.events)
370 if inputInfo.label!=
'':
371 line +=
', LABEL: ' +inputInfo.label
372 line +=
', LOCATION:'+inputInfo.location
375 line +=
' @@@ '+commands[0]
377 line=line.replace(
'DQMIO',
'DQM')
379 outFile.write(line+
'\n')
382 outFile.write(
'\n'+
'\n')
383 if step1Only:
continue
385 for (index,s)
in enumerate(indexAndSteps):
386 for (stepName,cmd)
in s:
388 if 'dasquery.log' in cmd:
continue
389 line =
'STEP%d ++ '%(stepIndex,) +stepName +
' @@@ '+cmd
391 line=line.replace(
'DQMIO',
'DQM')
392 outFile.write(line+
'\n')
393 outFile.write(
'\n'+
'\n')
395 print "wrote ",writtenWF,
' workflow'+(
's' if (writtenWF!=1)
else ''),
' to ', outFile.name
401 if 'cms/caf/cms' in os.environ[
'CMS_PATH']:
406 if isinstance(workflow.cmds[0], InputInfo):
407 if cafVeto
and (workflow.cmds[0].location ==
'CAF' and not onCAF):
409 workflows.append(workflow)
414 if selected: selected =
map(float,selected)
417 fmt1 =
"%-6s %-35s [1]: %s ..."
418 fmt2 =
" %35s [%d]: %s ..."
419 print "\nfound a total of ", len(wfs),
' workflows:'
421 print " of which the following", len(selected),
'were selected:'
424 fmt1 =
"%-6s %-35s [1]: %s "
425 fmt2 =
" %35s [%d]: %s"
429 if selected
and float(wf.numId)
not in selected:
continue
430 if extended:
print ''
432 for i
in range(len(N),len(wf.cmds)): N.append(0)
434 wfName, stepNames = wf.nameId.split(
'+',1)
435 for i,s
in enumerate(wf.cmds):
438 print fmt1 % (wf.numId, stepNames, (str(s)+
' ')[:maxLen])
440 print fmt2 % (
' ', i+1, (str(s)+
' ')[:maxLen])
442 print "%-6s %-35s "% (wf.numId, stepNames)
445 for i,n
in enumerate(N):
446 if n:
print n,
'workflows with',i+1,
'steps'
455 keyList = self.workFlowSteps.keys()
459 if pref != prefixIn :
continue
464 num, name, commands, stepList = val
465 nameId = str(num)+
'_'+name
467 print "==> duplicate name found for ", nameId
468 print ' keeping : ', self.
nameList[nameId]
469 print ' ignoring : ', val
473 self.workFlows.append(
WorkFlow(num, name, commands=commands))
477 def prepare(self, useInput=None, refRel='', fromScratch=None):
479 for matrixFile
in self.
files:
480 if self.
what !=
'all' and self.
what not in matrixFile:
481 print "ignoring non-requested file",matrixFile
484 print "ignoring",matrixFile,
"from default matrix"
488 self.
readMatrix(matrixFile, useInput, refRel, fromScratch)
490 print "ERROR reading file:", matrixFile, str(e)
496 print "ERROR creating workflows :", str(e)
500 def show(self, selected=None, extended=True, cafVeto=True):
503 print '\n',
'-'*80,
'\n'
509 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)