4 from Configuration.PyReleaseValidation.WorkFlow
import WorkFlow
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-'
56 self.
files = [
'relval_standard' ,
70 'relval_highstats':
True ,
72 'relval_generator':
True,
73 'relval_extendedgen':
True,
74 'relval_production':
True,
76 'relval_upgrade':
False,
77 'relval_identity':
False,
78 'relval_machine':
True,
92 for k,v
in step.items():
93 if 'no_exec' in k :
continue
94 if k.lower() ==
'cfg':
97 if k.lower() ==
'input':
104 cmd +=
' ' + k +
' ' + str(v)
105 return cfg, input, cmd
109 if len(overrides.keys()) > 0:
110 copyStep=
merge([overrides]+[step])
115 def readMatrix(self, fileNameIn, useInput=None, refRel=None, fromScratch=None):
119 print "processing", fileNameIn
122 _tmpMod = __import__(
'Configuration.PyReleaseValidation.'+fileNameIn )
123 self.
relvalModule = sys.modules[
'Configuration.PyReleaseValidation.'+fileNameIn]
125 print "ERROR importing file ", fileNameIn, str(e)
128 if useInput
is not None:
129 print "request for INPUT for ", useInput
139 for k
in self.relvalModule.workflows.keys():
140 fromInput[float(k)]=int(il)
142 fromInput[float(ik)]=int(il)
145 for k
in self.relvalModule.workflows.keys():
146 fromInput[float(k)]=0
148 fromInput[float(i)]=0
151 fromScratch=
map(float,fromScratch)
152 for num
in fromScratch:
158 self.relvalModule.steps.overwrite(p)
163 refRels=refRel.split(
',')
164 if len(refRels)!=len(self.relvalModule.baseDataSetRelease):
166 self.relvalModule.changeRefRelease(
167 self.relvalModule.steps,
168 zip(self.relvalModule.baseDataSetRelease,refRels)
171 self.relvalModule.changeRefRelease(
172 self.relvalModule.steps,
173 [(x,refRel)
for x
in self.relvalModule.baseDataSetRelease]
177 for num, wfInfo
in self.relvalModule.workflows.items():
181 stepOverrides=wfInfo.overrides
183 if wfName.strip() ==
'': wfName = stepList[0]
189 if not type(addCom)==list: addCom=[addCom]
194 while len(addTo)!=len(stepList):
203 ilevel=fromInput[num]
205 for (stepIr,step)
in enumerate(reversed(stepList)):
207 stepI=(len(stepList)-stepIr)-1
213 testName=
'__'.
join(stepList[0:stepI+1])+
'INPUT'
215 testName=step+
'INPUT'
217 if testName
in self.relvalModule.steps.keys():
219 stepList[stepI]=testName
222 for p
in range(stepI):
228 for (stepI,step)
in enumerate(stepList):
234 'RECODFROMRAWRECO',
'SKIMD',
'SKIMCOSD',
'SKIMDreHLT'
240 if len(name) > 0 : name +=
'+'
245 if step+'INPUT' in self.relvalModule.steps.keys():
246 stepName = step+"INPUT"
247 stepList.remove(step)
248 stepList.insert(stepIndex,stepName)
251 if addCom
and (
not addTo
or addTo[stepIndex]==1):
253 copyStep=
merge(addCom+[self.
makeStep(self.relvalModule.steps[stepName],stepOverrides)])
254 cfg, input, opts = self.
makeCmd(copyStep)
256 cfg, input, opts = self.
makeCmd(self.
makeStep(self.relvalModule.steps[stepName],stepOverrides))
259 msg =
"FATAL ERROR: found both cfg and input for workflow "+str(num)+
' step '+stepName
268 cmd =
'cmsDriver.py '+cfg+
' '+opts
270 cmd =
'cmsDriver.py step'+str(stepIndex+1)+
' '+opts
272 cmd+=
' --io %s.io --python %s.py'%(stepName,stepName)
275 if stepIndex
in self.
apply or stepName
in self.
apply:
280 cmd=cmd.replace(
'DQMIO',
'DQM')
281 cmd=cmd.replace(
'--filetype DQM',
'')
283 ranStepList.append(stepName)
286 self.
workFlowSteps[(num,prefix)] = (num, name, commands, ranStepList)
291 def showRaw(self, useInput, refRel=None, fromScratch=None, what='all',step1Only=False,selected=None):
294 selected=
map(float,selected)
295 for matrixFile
in self.
files:
299 if self.
what !=
'all' and self.
what not in matrixFile:
300 print "ignoring non-requested file",matrixFile
304 print "ignoring file not used by default (enable with -w)",matrixFile
308 self.
readMatrix(matrixFile, useInput, refRel, fromScratch)
310 print "ERROR reading file:", matrixFile, str(e)
315 dataFileName = matrixFile.replace(
'relval_',
'cmsDriver_')+
'_hlt.txt'
316 outFile = open(dataFileName,
'w')
318 print "found ", len(self.workFlowSteps.keys()),
' workflows for ', dataFileName
319 ids = self.workFlowSteps.keys()
325 if selected
and not (key[0]
in selected):
328 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
331 wfName,stepNames= name.split(
'+',1)
333 stepNames=stepNames.replace(
'+RECODFROMRAWRECO',
'')
334 stepNames=stepNames.replace(
'+SKIMCOSD',
'')
335 stepNames=stepNames.replace(
'+SKIMD',
'')
336 if 'HARVEST' in stepNames:
338 exactb=stepNames.index(
'+HARVEST')
339 exacte=stepNames.index(
'+',exactb+1)
if (
'+' in stepNames[exactb+1:])
else (len(stepNames))
340 stepNames=stepNames.replace(stepNames[exactb:exacte],
'')
343 step1,otherSteps = stepNames.split(
'+',1)
345 line = str(num) +
' ++ '+ wfName
346 if otherSteps
and not step1Only:
347 line +=
' ++ ' +otherSteps.replace(
'+',
',')
351 if not isinstance(commands[0],str):
352 inputInfo=commands[0]
354 for (i,c)
in enumerate(otherSteps.split(
'+')):
356 for p
in range(len(indexAndSteps),i+2):
357 indexAndSteps.append(set())
358 indexAndSteps[i+1].
add((c,commands[i+1]))
362 if step1Only:
continue
363 line +=
' ++ REALDATA: '+inputInfo.dataSet
364 if inputInfo.run!=[]: line +=
', RUN:'+
'|'.
join(
map(str,inputInfo.run))
365 line +=
', FILES: ' +str(inputInfo.files)
366 line +=
', EVENTS: '+str(inputInfo.events)
367 if inputInfo.label!=
'':
368 line +=
', LABEL: ' +inputInfo.label
369 line +=
', LOCATION:'+inputInfo.location
372 line +=
' @@@ '+commands[0]
374 line=line.replace(
'DQMIO',
'DQM')
376 outFile.write(line+
'\n')
379 outFile.write(
'\n'+
'\n')
380 if step1Only:
continue
382 for (index,s)
in enumerate(indexAndSteps):
383 for (stepName,cmd)
in s:
385 if 'dasquery.log' in cmd:
continue
386 line =
'STEP%d ++ '%(stepIndex,) +stepName +
' @@@ '+cmd
388 line=line.replace(
'DQMIO',
'DQM')
389 outFile.write(line+
'\n')
390 outFile.write(
'\n'+
'\n')
392 print "wrote ",writtenWF,
' workflow'+(
's' if (writtenWF!=1)
else ''),
' to ', outFile.name
397 if selected: selected =
map(float,selected)
399 fmt1 =
"%-6s %-35s [1]: %s ..."
400 fmt2 =
" %35s [%d]: %s ..."
401 print "\nfound a total of ", len(self.
workFlows),
' workflows:'
403 print " of which the following", len(selected),
'were selected:'
406 fmt1 =
"%-6s %-35s [1]: %s "
407 fmt2 =
" %35s [%d]: %s"
411 if selected
and float(wf.numId)
not in selected:
continue
412 if extended:
print ''
414 for i
in range(len(N),len(wf.cmds)): N.append(0)
416 wfName, stepNames = wf.nameId.split(
'+',1)
417 for i,s
in enumerate(wf.cmds):
420 print fmt1 % (wf.numId, stepNames, (str(s)+
' ')[:maxLen])
422 print fmt2 % (
' ', i+1, (str(s)+
' ')[:maxLen])
424 print "%-6s %-35s "% (wf.numId, stepNames)
427 for i,n
in enumerate(N):
428 if n:
print n,
'workflows with',i+1,
'steps'
437 keyList = self.workFlowSteps.keys()
441 if pref != prefixIn :
continue
446 num, name, commands, stepList = val
447 nameId = str(num)+
'_'+name
449 print "==> duplicate name found for ", nameId
450 print ' keeping : ', self.
nameList[nameId]
451 print ' ignoring : ', val
455 self.workFlows.append(
WorkFlow(num, name, commands=commands))
459 def prepare(self, useInput=None, refRel='', fromScratch=None):
461 for matrixFile
in self.
files:
462 if self.
what !=
'all' and self.
what not in matrixFile:
463 print "ignoring non-requested file",matrixFile
466 print "ignoring",matrixFile,
"from default matrix"
470 self.
readMatrix(matrixFile, useInput, refRel, fromScratch)
472 print "ERROR reading file:", matrixFile, str(e)
478 print "ERROR creating workflows :", str(e)
482 def show(self, selected=None, extended=True):
485 print '\n',
'-'*80,
'\n'
491 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)