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 ranStepList.append(stepName)
252 self.
workFlowSteps[(num,prefix)] = (num, name, commands, ranStepList)
257 def showRaw(self, useInput, refRel=None, fromScratch=None, what='all',step1Only=False,selected=None):
260 selected=
map(float,selected)
261 for matrixFile
in self.
files:
265 if self.
what !=
'all' and self.
what not in matrixFile:
266 print "ignoring non-requested file",matrixFile
270 self.
readMatrix(matrixFile, useInput, refRel, fromScratch)
272 print "ERROR reading file:", matrixFile, str(e)
277 dataFileName = matrixFile.replace(
'relval_',
'cmsDriver_')+
'_hlt.txt'
278 outFile = open(dataFileName,
'w')
280 print "found ", len(self.workFlowSteps.keys()),
' workflows for ', dataFileName
281 ids = self.workFlowSteps.keys()
287 if selected
and not (key[0]
in selected):
290 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
293 wfName,stepNames= name.split(
'+',1)
295 stepNames=stepNames.replace(
'+RECODFROMRAWRECO',
'')
296 stepNames=stepNames.replace(
'+SKIMCOSD',
'')
297 stepNames=stepNames.replace(
'+SKIMD',
'')
298 if 'HARVEST' in stepNames:
300 exactb=stepNames.index(
'+HARVEST')
301 exacte=stepNames.index(
'+',exactb+1)
if (
'+' in stepNames[exactb+1:])
else (len(stepNames))
302 stepNames=stepNames.replace(stepNames[exactb:exacte],
'')
305 step1,otherSteps = stepNames.split(
'+',1)
307 line = str(num) +
' ++ '+ wfName
308 if otherSteps
and not step1Only:
309 line +=
' ++ ' +otherSteps.replace(
'+',
',')
313 if not isinstance(commands[0],str):
314 inputInfo=commands[0]
316 for (i,c)
in enumerate(otherSteps.split(
'+')):
318 for p
in range(len(indexAndSteps),i+2):
319 indexAndSteps.append(set())
320 indexAndSteps[i+1].
add((c,commands[i+1]))
324 if step1Only:
continue
325 line +=
' ++ REALDATA: '+inputInfo.dataSet
326 if inputInfo.run!=[]: line +=
', RUN:'+
'|'.
join(
map(str,inputInfo.run))
327 line +=
', FILES: ' +str(inputInfo.files)
328 line +=
', EVENTS: '+str(inputInfo.events)
329 if inputInfo.label!=
'':
330 line +=
', LABEL: ' +inputInfo.label
331 line +=
', LOCATION:'+inputInfo.location
334 line +=
' @@@ '+commands[0]
336 outFile.write(line+
'\n')
339 outFile.write(
'\n'+
'\n')
340 if step1Only:
continue
342 for (index,s)
in enumerate(indexAndSteps):
343 for (stepName,cmd)
in s:
345 if 'dasquery.log' in cmd:
continue
346 line =
'STEP%d ++ '%(stepIndex,) +stepName +
' @@@ '+cmd
347 outFile.write(line+
'\n')
348 outFile.write(
'\n'+
'\n')
350 print "wrote ",writtenWF,
' workflow'+(
's' if (writtenWF!=1)
else ''),
' to ', outFile.name
355 if selected: selected =
map(float,selected)
357 fmt1 =
"%-6s %-35s [1]: %s ..."
358 fmt2 =
" %35s [%d]: %s ..."
359 print "\nfound a total of ", len(self.
workFlows),
' workflows:'
361 print " of which the following", len(selected),
'were selected:'
364 fmt1 =
"%-6s %-35s [1]: %s "
365 fmt2 =
" %35s [%d]: %s"
369 if selected
and float(wf.numId)
not in selected:
continue
370 if extended:
print ''
372 for i
in range(len(N),len(wf.cmds)): N.append(0)
374 wfName, stepNames = wf.nameId.split(
'+',1)
375 for i,s
in enumerate(wf.cmds):
378 print fmt1 % (wf.numId, stepNames, (str(s)+
' ')[:maxLen])
380 print fmt2 % (
' ', i+1, (str(s)+
' ')[:maxLen])
382 print "%-6s %-35s "% (wf.numId, stepNames)
385 for i,n
in enumerate(N):
386 if n:
print n,
'workflows with',i+1,
'steps'
395 keyList = self.workFlowSteps.keys()
399 if pref != prefixIn :
continue
404 num, name, commands, stepList = val
405 nameId = str(num)+
'_'+name
407 print "==> duplicate name found for ", nameId
408 print ' keeping : ', self.
nameList[nameId]
409 print ' ignoring : ', val
413 self.workFlows.append(
WorkFlow(num, name, commands=commands))
417 def prepare(self, useInput=None, refRel='', fromScratch=None):
419 for matrixFile
in self.
files:
420 if self.
what !=
'all' and self.
what not in matrixFile:
421 print "ignoring non-requested file",matrixFile
423 if self.
what ==
'all' and (
'upgrade' in matrixFile):
424 print "ignoring",matrixFile,
"from default matrix"
428 self.
readMatrix(matrixFile, useInput, refRel, fromScratch)
430 print "ERROR reading file:", matrixFile, str(e)
436 print "ERROR creating workflows :", str(e)
440 def show(self, selected=None, extended=True):
443 print '\n',
'-'*80,
'\n'
449 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)