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-'
52 self.
files = [
'relval_standard' ,
71 for k,v
in step.items():
72 if 'no_exec' in k :
continue
73 if k.lower() ==
'cfg':
76 if k.lower() ==
'input':
83 cmd +=
' ' + k +
' ' + str(v)
84 return cfg, input, cmd
86 def readMatrix(self, fileNameIn, useInput=None, refRel=None, fromScratch=None):
90 print "processing ", fileNameIn
93 _tmpMod = __import__(
'Configuration.PyReleaseValidation.'+fileNameIn )
94 self.
relvalModule = sys.modules[
'Configuration.PyReleaseValidation.'+fileNameIn]
96 print "ERROR importing file ", fileNameIn, str(e)
99 print "request for INPUT for ", useInput
109 for k
in self.relvalModule.workflows.keys():
110 fromInput[float(k)]=int(il)
112 fromInput[float(ik)]=int(il)
115 for k
in self.relvalModule.workflows.keys():
116 fromInput[float(k)]=0
118 fromInput[float(i)]=0
121 fromScratch=
map(float,fromScratch)
122 for num
in fromScratch:
128 self.relvalModule.steps.overwrite(p)
133 refRels=refRel.split(
',')
134 if len(refRels)!=len(self.relvalModule.baseDataSetRelease):
136 self.relvalModule.changeRefRelease(
137 self.relvalModule.steps,
138 zip(self.relvalModule.baseDataSetRelease,refRels)
141 self.relvalModule.changeRefRelease(
142 self.relvalModule.steps,
143 [(x,refRel)
for x
in self.relvalModule.baseDataSetRelease]
147 for num, wfInfo
in self.relvalModule.workflows.items():
152 if wfName.strip() ==
'': wfName = stepList[0]
158 if not type(addCom)==list: addCom=[addCom]
163 while len(addTo)!=len(stepList):
172 ilevel=fromInput[num]
174 for (stepIr,step)
in enumerate(reversed(stepList)):
176 stepI=(len(stepList)-stepIr)-1
182 testName=
'__'.
join(stepList[0:stepI+1])+
'INPUT'
184 testName=step+
'INPUT'
186 if testName
in self.relvalModule.steps.keys():
188 stepList[stepI]=testName
191 for p
in range(stepI):
197 for (stepI,step)
in enumerate(stepList):
203 'RECODFROMRAWRECO',
'SKIMD',
'SKIMCOSD',
'SKIMDreHLT'
209 if len(name) > 0 : name +=
'+'
214 if step+'INPUT' in self.relvalModule.steps.keys():
215 stepName = step+"INPUT"
216 stepList.remove(step)
217 stepList.insert(stepIndex,stepName)
221 if addCom
and (
not addTo
or addTo[stepIndex]==1):
223 copyStep=
merge(addCom+[self.relvalModule.steps[stepName]])
224 cfg, input, opts = self.
makeCmd(copyStep)
226 cfg, input, opts = self.
makeCmd(self.relvalModule.steps[stepName])
229 msg =
"FATAL ERROR: found both cfg and input for workflow "+str(num)+
' step '+stepName
238 cmd =
'cmsDriver.py '+cfg+
' '+opts
240 cmd =
'cmsDriver.py step'+str(stepIndex+1)+
' '+opts
242 cmd+=
' --io %s.io --python %s.py'%(stepName,stepName)
245 if stepIndex
in self.
apply or stepName
in self.
apply:
250 cmd=cmd.replace(
'DQMROOT',
'DQM')
251 cmd=cmd.replace(
'--filetype DQM',
'')
253 ranStepList.append(stepName)
256 self.
workFlowSteps[(num,prefix)] = (num, name, commands, ranStepList)
261 def showRaw(self, useInput, refRel=None, fromScratch=None, what='all',step1Only=False,selected=None):
264 selected=
map(float,selected)
265 for matrixFile
in self.
files:
269 if self.
what !=
'all' and self.
what not in matrixFile:
270 print "ignoring non-requested file",matrixFile
274 self.
readMatrix(matrixFile, useInput, refRel, fromScratch)
276 print "ERROR reading file:", matrixFile, str(e)
281 dataFileName = matrixFile.replace(
'relval_',
'cmsDriver_')+
'_hlt.txt'
282 outFile = open(dataFileName,
'w')
284 print "found ", len(self.workFlowSteps.keys()),
' workflows for ', dataFileName
285 ids = self.workFlowSteps.keys()
291 if selected
and not (key[0]
in selected):
294 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
297 wfName,stepNames= name.split(
'+',1)
299 stepNames=stepNames.replace(
'+RECODFROMRAWRECO',
'')
300 stepNames=stepNames.replace(
'+SKIMCOSD',
'')
301 stepNames=stepNames.replace(
'+SKIMD',
'')
302 if 'HARVEST' in stepNames:
304 exactb=stepNames.index(
'+HARVEST')
305 exacte=stepNames.index(
'+',exactb+1)
if (
'+' in stepNames[exactb+1:])
else (len(stepNames))
306 stepNames=stepNames.replace(stepNames[exactb:exacte],
'')
309 step1,otherSteps = stepNames.split(
'+',1)
311 line = str(num) +
' ++ '+ wfName
312 if otherSteps
and not step1Only:
313 line +=
' ++ ' +otherSteps.replace(
'+',
',')
317 if not isinstance(commands[0],str):
318 inputInfo=commands[0]
320 for (i,c)
in enumerate(otherSteps.split(
'+')):
322 for p
in range(len(indexAndSteps),i+2):
323 indexAndSteps.append(set())
324 indexAndSteps[i+1].
add((c,commands[i+1]))
328 if step1Only:
continue
329 line +=
' ++ REALDATA: '+inputInfo.dataSet
330 if inputInfo.run!=[]: line +=
', RUN:'+
'|'.
join(
map(str,inputInfo.run))
331 line +=
', FILES: ' +str(inputInfo.files)
332 line +=
', EVENTS: '+str(inputInfo.events)
333 if inputInfo.label!=
'':
334 line +=
', LABEL: ' +inputInfo.label
335 line +=
', LOCATION:'+inputInfo.location
338 line +=
' @@@ '+commands[0]
340 line=line.replace(
'DQMROOT',
'DQM')
342 outFile.write(line+
'\n')
345 outFile.write(
'\n'+
'\n')
346 if step1Only:
continue
348 for (index,s)
in enumerate(indexAndSteps):
349 for (stepName,cmd)
in s:
351 if 'dasquery.log' in cmd:
continue
352 line =
'STEP%d ++ '%(stepIndex,) +stepName +
' @@@ '+cmd
354 line=line.replace(
'DQMROOT',
'DQM')
355 outFile.write(line+
'\n')
356 outFile.write(
'\n'+
'\n')
358 print "wrote ",writtenWF,
' workflow'+(
's' if (writtenWF!=1)
else ''),
' to ', outFile.name
363 if selected: selected =
map(float,selected)
365 fmt1 =
"%-6s %-35s [1]: %s ..."
366 fmt2 =
" %35s [%d]: %s ..."
367 print "\nfound a total of ", len(self.
workFlows),
' workflows:'
369 print " of which the following", len(selected),
'were selected:'
372 fmt1 =
"%-6s %-35s [1]: %s "
373 fmt2 =
" %35s [%d]: %s"
377 if selected
and float(wf.numId)
not in selected:
continue
378 if extended:
print ''
380 for i
in range(len(N),len(wf.cmds)): N.append(0)
382 wfName, stepNames = wf.nameId.split(
'+',1)
383 for i,s
in enumerate(wf.cmds):
386 print fmt1 % (wf.numId, stepNames, (str(s)+
' ')[:maxLen])
388 print fmt2 % (
' ', i+1, (str(s)+
' ')[:maxLen])
390 print "%-6s %-35s "% (wf.numId, stepNames)
393 for i,n
in enumerate(N):
394 if n:
print n,
'workflows with',i+1,
'steps'
403 keyList = self.workFlowSteps.keys()
407 if pref != prefixIn :
continue
412 num, name, commands, stepList = val
413 nameId = str(num)+
'_'+name
415 print "==> duplicate name found for ", nameId
416 print ' keeping : ', self.
nameList[nameId]
417 print ' ignoring : ', val
421 self.workFlows.append(
WorkFlow(num, name, commands=commands))
425 def prepare(self, useInput=None, refRel='', fromScratch=None):
427 for matrixFile
in self.
files:
428 if self.
what !=
'all' and self.
what not in matrixFile:
429 print "ignoring non-requested file",matrixFile
431 if self.
what ==
'all' and (
'upgrade' in matrixFile):
432 print "ignoring",matrixFile,
"from default matrix"
436 self.
readMatrix(matrixFile, useInput, refRel, fromScratch)
438 print "ERROR reading file:", matrixFile, str(e)
444 print "ERROR creating workflows :", str(e)
448 def show(self, selected=None, extended=True):
451 print '\n',
'-'*80,
'\n'
457 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)