4 from Configuration.PyReleaseValidation.WorkFlow
import WorkFlow
42 'relval_highstats':
'hi-' ,
43 'relval_pileup':
'PU-' ,
44 'relval_generator':
'gen-' ,
45 'relval_production':
'prod-' ,
47 'relval_upgrade':
'upg-',
48 'relval_identity':
'id-'
51 self.
files = [
'relval_standard' ,
70 for k,v
in step.items():
71 if 'no_exec' in k :
continue
72 if k.lower() ==
'cfg':
75 if k.lower() ==
'input':
82 cmd +=
' ' + k +
' ' + str(v)
83 return cfg, input, cmd
85 def readMatrix(self, fileNameIn, useInput=None, refRel=None, fromScratch=None):
89 print "processing ", fileNameIn
92 _tmpMod = __import__(
'Configuration.PyReleaseValidation.'+fileNameIn )
93 self.
relvalModule = sys.modules[
'Configuration.PyReleaseValidation.'+fileNameIn]
95 print "ERROR importing file ", fileNameIn, str(e)
98 print "request for INPUT for ", useInput
108 for k
in self.relvalModule.workflows.keys():
109 fromInput[float(k)]=int(il)
111 fromInput[float(ik)]=int(il)
114 for k
in self.relvalModule.workflows.keys():
115 fromInput[float(k)]=0
117 fromInput[float(i)]=0
120 fromScratch=
map(float,fromScratch)
121 for num
in fromScratch:
127 self.relvalModule.steps.overwrite(p)
132 refRels=refRel.split(
',')
133 if len(refRels)!=len(self.relvalModule.baseDataSetRelease):
135 self.relvalModule.changeRefRelease(
136 self.relvalModule.steps,
137 zip(self.relvalModule.baseDataSetRelease,refRels)
140 self.relvalModule.changeRefRelease(
141 self.relvalModule.steps,
142 [(x,refRel)
for x
in self.relvalModule.baseDataSetRelease]
146 for num, wfInfo
in self.relvalModule.workflows.items():
151 if wfName.strip() ==
'': wfName = stepList[0]
157 if not type(addCom)==list: addCom=[addCom]
162 while len(addTo)!=len(stepList):
171 ilevel=fromInput[num]
173 for (stepIr,step)
in enumerate(reversed(stepList)):
175 stepI=(len(stepList)-stepIr)-1
181 testName=
'__'.
join(stepList[0:stepI+1])+
'INPUT'
183 testName=step+
'INPUT'
185 if testName
in self.relvalModule.steps.keys():
187 stepList[stepI]=testName
190 for p
in range(stepI):
196 for (stepI,step)
in enumerate(stepList):
202 'RECODFROMRAWRECO',
'SKIMD',
'SKIMCOSD',
'SKIMDreHLT'
208 if len(name) > 0 : name +=
'+'
213 if step+'INPUT' in self.relvalModule.steps.keys():
214 stepName = step+"INPUT"
215 stepList.remove(step)
216 stepList.insert(stepIndex,stepName)
220 if addCom
and (
not addTo
or addTo[stepIndex]==1):
222 copyStep=
merge(addCom+[self.relvalModule.steps[stepName]])
223 cfg, input, opts = self.
makeCmd(copyStep)
225 cfg, input, opts = self.
makeCmd(self.relvalModule.steps[stepName])
228 msg =
"FATAL ERROR: found both cfg and input for workflow "+str(num)+
' step '+stepName
237 cmd =
'cmsDriver.py '+cfg+
' '+opts
239 cmd =
'cmsDriver.py step'+str(stepIndex+1)+
' '+opts
241 cmd+=
' --io %s.io --python %s.py'%(stepName,stepName)
244 if stepIndex
in self.
apply or stepName
in self.
apply:
249 cmd=cmd.replace(
'DQMROOT',
'DQM')
250 cmd=cmd.replace(
'--filetype DQM',
'')
252 ranStepList.append(stepName)
255 self.
workFlowSteps[(num,prefix)] = (num, name, commands, ranStepList)
260 def showRaw(self, useInput, refRel=None, fromScratch=None, what='all',step1Only=False,selected=None):
263 selected=
map(float,selected)
264 for matrixFile
in self.
files:
268 if self.
what !=
'all' and self.
what not in matrixFile:
269 print "ignoring non-requested file",matrixFile
273 self.
readMatrix(matrixFile, useInput, refRel, fromScratch)
275 print "ERROR reading file:", matrixFile, str(e)
280 dataFileName = matrixFile.replace(
'relval_',
'cmsDriver_')+
'_hlt.txt'
281 outFile = open(dataFileName,
'w')
283 print "found ", len(self.workFlowSteps.keys()),
' workflows for ', dataFileName
284 ids = self.workFlowSteps.keys()
290 if selected
and not (key[0]
in selected):
293 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
296 wfName,stepNames= name.split(
'+',1)
298 stepNames=stepNames.replace(
'+RECODFROMRAWRECO',
'')
299 stepNames=stepNames.replace(
'+SKIMCOSD',
'')
300 stepNames=stepNames.replace(
'+SKIMD',
'')
301 if 'HARVEST' in stepNames:
303 exactb=stepNames.index(
'+HARVEST')
304 exacte=stepNames.index(
'+',exactb+1)
if (
'+' in stepNames[exactb+1:])
else (len(stepNames))
305 stepNames=stepNames.replace(stepNames[exactb:exacte],
'')
308 step1,otherSteps = stepNames.split(
'+',1)
310 line = str(num) +
' ++ '+ wfName
311 if otherSteps
and not step1Only:
312 line +=
' ++ ' +otherSteps.replace(
'+',
',')
316 if not isinstance(commands[0],str):
317 inputInfo=commands[0]
319 for (i,c)
in enumerate(otherSteps.split(
'+')):
321 for p
in range(len(indexAndSteps),i+2):
322 indexAndSteps.append(set())
323 indexAndSteps[i+1].
add((c,commands[i+1]))
327 if step1Only:
continue
328 line +=
' ++ REALDATA: '+inputInfo.dataSet
329 if inputInfo.run!=[]: line +=
', RUN:'+
'|'.
join(
map(str,inputInfo.run))
330 line +=
', FILES: ' +str(inputInfo.files)
331 line +=
', EVENTS: '+str(inputInfo.events)
332 if inputInfo.label!=
'':
333 line +=
', LABEL: ' +inputInfo.label
334 line +=
', LOCATION:'+inputInfo.location
337 line +=
' @@@ '+commands[0]
338 line=line.replace(
'DQMROOT',
'DQM')
340 outFile.write(line+
'\n')
343 outFile.write(
'\n'+
'\n')
344 if step1Only:
continue
346 for (index,s)
in enumerate(indexAndSteps):
347 for (stepName,cmd)
in s:
349 if 'dbsquery.log' in cmd:
continue
350 line =
'STEP%d ++ '%(stepIndex,) +stepName +
' @@@ '+cmd
351 line=line.replace(
'DQMROOT',
'DQM')
352 outFile.write(line+
'\n')
353 outFile.write(
'\n'+
'\n')
355 print "wrote ",writtenWF,
' workflow'+(
's' if (writtenWF!=1)
else ''),
' to ', outFile.name
360 if selected: selected =
map(float,selected)
362 fmt1 =
"%-6s %-35s [1]: %s ..."
363 fmt2 =
" %35s [%d]: %s ..."
364 print "\nfound a total of ", len(self.
workFlows),
' workflows:'
366 print " of which the following", len(selected),
'were selected:'
369 fmt1 =
"%-6s %-35s [1]: %s "
370 fmt2 =
" %35s [%d]: %s"
374 if selected
and float(wf.numId)
not in selected:
continue
375 if extended:
print ''
377 for i
in range(len(N),len(wf.cmds)): N.append(0)
379 wfName, stepNames = wf.nameId.split(
'+',1)
380 for i,s
in enumerate(wf.cmds):
383 print fmt1 % (wf.numId, stepNames, (str(s)+
' ')[:maxLen])
385 print fmt2 % (
' ', i+1, (str(s)+
' ')[:maxLen])
387 print "%-6s %-35s "% (wf.numId, stepNames)
390 for i,n
in enumerate(N):
391 if n:
print n,
'workflows with',i+1,
'steps'
400 keyList = self.workFlowSteps.keys()
404 if pref != prefixIn :
continue
409 num, name, commands, stepList = val
410 nameId = str(num)+
'_'+name
412 print "==> duplicate name found for ", nameId
413 print ' keeping : ', self.
nameList[nameId]
414 print ' ignoring : ', val
418 self.workFlows.append(
WorkFlow(num, name, commands=commands))
422 def prepare(self, useInput=None, refRel='', fromScratch=None):
424 for matrixFile
in self.
files:
425 if self.
what !=
'all' and self.
what not in matrixFile:
426 print "ignoring non-requested file",matrixFile
428 if self.
what ==
'all' and (
'upgrade' in matrixFile):
429 print "ignoring",matrixFile,
"from default matrix"
433 self.
readMatrix(matrixFile, useInput, refRel, fromScratch)
435 print "ERROR reading file:", matrixFile, str(e)
441 print "ERROR creating workflows :", str(e)
445 def show(self, selected=None, extended=True):
448 print '\n',
'-'*80,
'\n'
454 pickle.dump(self.
workFlows, open(
'theMatrix.pkl',
'w') )
void add(const std::vector< const T * > &source, std::vector< const T * > &dest)
static std::string join(char **cmd)