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-'
54 self.
files = [
'relval_standard' ,
75 for k,v
in step.items():
76 if 'no_exec' in k :
continue
77 if k.lower() ==
'cfg':
80 if k.lower() ==
'input':
87 cmd +=
' ' + k +
' ' + str(v)
88 return cfg, input, cmd
90 def readMatrix(self, fileNameIn, useInput=None, refRel=None, fromScratch=None):
94 print "processing ", fileNameIn
97 _tmpMod = __import__(
'Configuration.PyReleaseValidation.'+fileNameIn )
98 self.
relvalModule = sys.modules[
'Configuration.PyReleaseValidation.'+fileNameIn]
100 print "ERROR importing file ", fileNameIn, str(e)
103 print "request for INPUT for ", useInput
113 for k
in self.relvalModule.workflows.keys():
114 fromInput[float(k)]=int(il)
116 fromInput[float(ik)]=int(il)
119 for k
in self.relvalModule.workflows.keys():
120 fromInput[float(k)]=0
122 fromInput[float(i)]=0
125 fromScratch=
map(float,fromScratch)
126 for num
in fromScratch:
132 self.relvalModule.steps.overwrite(p)
137 refRels=refRel.split(
',')
138 if len(refRels)!=len(self.relvalModule.baseDataSetRelease):
140 self.relvalModule.changeRefRelease(
141 self.relvalModule.steps,
142 zip(self.relvalModule.baseDataSetRelease,refRels)
145 self.relvalModule.changeRefRelease(
146 self.relvalModule.steps,
147 [(x,refRel)
for x
in self.relvalModule.baseDataSetRelease]
151 for num, wfInfo
in self.relvalModule.workflows.items():
156 if wfName.strip() ==
'': wfName = stepList[0]
162 if not type(addCom)==list: addCom=[addCom]
167 while len(addTo)!=len(stepList):
176 ilevel=fromInput[num]
178 for (stepIr,step)
in enumerate(reversed(stepList)):
180 stepI=(len(stepList)-stepIr)-1
186 testName=
'__'.
join(stepList[0:stepI+1])+
'INPUT'
188 testName=step+
'INPUT'
190 if testName
in self.relvalModule.steps.keys():
192 stepList[stepI]=testName
195 for p
in range(stepI):
201 for (stepI,step)
in enumerate(stepList):
207 'RECODFROMRAWRECO',
'SKIMD',
'SKIMCOSD',
'SKIMDreHLT'
213 if len(name) > 0 : name +=
'+'
218 if step+'INPUT' in self.relvalModule.steps.keys():
219 stepName = step+"INPUT"
220 stepList.remove(step)
221 stepList.insert(stepIndex,stepName)
225 if addCom
and (
not addTo
or addTo[stepIndex]==1):
227 copyStep=
merge(addCom+[self.relvalModule.steps[stepName]])
228 cfg, input, opts = self.
makeCmd(copyStep)
230 cfg, input, opts = self.
makeCmd(self.relvalModule.steps[stepName])
233 msg =
"FATAL ERROR: found both cfg and input for workflow "+str(num)+
' step '+stepName
242 cmd =
'cmsDriver.py '+cfg+
' '+opts
244 cmd =
'cmsDriver.py step'+str(stepIndex+1)+
' '+opts
246 cmd+=
' --io %s.io --python %s.py'%(stepName,stepName)
249 if stepIndex
in self.
apply or stepName
in self.
apply:
254 cmd=cmd.replace(
'DQMIO',
'DQM')
255 cmd=cmd.replace(
'--filetype DQM',
'')
257 ranStepList.append(stepName)
260 self.
workFlowSteps[(num,prefix)] = (num, name, commands, ranStepList)
265 def showRaw(self, useInput, refRel=None, fromScratch=None, what='all',step1Only=False,selected=None):
268 selected=
map(float,selected)
269 for matrixFile
in self.
files:
273 if self.
what !=
'all' and self.
what not in matrixFile:
274 print "ignoring non-requested file",matrixFile
278 self.
readMatrix(matrixFile, useInput, refRel, fromScratch)
280 print "ERROR reading file:", matrixFile, str(e)
285 dataFileName = matrixFile.replace(
'relval_',
'cmsDriver_')+
'_hlt.txt'
286 outFile = open(dataFileName,
'w')
288 print "found ", len(self.workFlowSteps.keys()),
' workflows for ', dataFileName
289 ids = self.workFlowSteps.keys()
295 if selected
and not (key[0]
in selected):
298 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
301 wfName,stepNames= name.split(
'+',1)
303 stepNames=stepNames.replace(
'+RECODFROMRAWRECO',
'')
304 stepNames=stepNames.replace(
'+SKIMCOSD',
'')
305 stepNames=stepNames.replace(
'+SKIMD',
'')
306 if 'HARVEST' in stepNames:
308 exactb=stepNames.index(
'+HARVEST')
309 exacte=stepNames.index(
'+',exactb+1)
if (
'+' in stepNames[exactb+1:])
else (len(stepNames))
310 stepNames=stepNames.replace(stepNames[exactb:exacte],
'')
313 step1,otherSteps = stepNames.split(
'+',1)
315 line = str(num) +
' ++ '+ wfName
316 if otherSteps
and not step1Only:
317 line +=
' ++ ' +otherSteps.replace(
'+',
',')
321 if not isinstance(commands[0],str):
322 inputInfo=commands[0]
324 for (i,c)
in enumerate(otherSteps.split(
'+')):
326 for p
in range(len(indexAndSteps),i+2):
327 indexAndSteps.append(set())
328 indexAndSteps[i+1].
add((c,commands[i+1]))
332 if step1Only:
continue
333 line +=
' ++ REALDATA: '+inputInfo.dataSet
334 if inputInfo.run!=[]: line +=
', RUN:'+
'|'.
join(
map(str,inputInfo.run))
335 line +=
', FILES: ' +str(inputInfo.files)
336 line +=
', EVENTS: '+str(inputInfo.events)
337 if inputInfo.label!=
'':
338 line +=
', LABEL: ' +inputInfo.label
339 line +=
', LOCATION:'+inputInfo.location
342 line +=
' @@@ '+commands[0]
344 line=line.replace(
'DQMIO',
'DQM')
346 outFile.write(line+
'\n')
349 outFile.write(
'\n'+
'\n')
350 if step1Only:
continue
352 for (index,s)
in enumerate(indexAndSteps):
353 for (stepName,cmd)
in s:
355 if 'dasquery.log' in cmd:
continue
356 line =
'STEP%d ++ '%(stepIndex,) +stepName +
' @@@ '+cmd
358 line=line.replace(
'DQMIO',
'DQM')
359 outFile.write(line+
'\n')
360 outFile.write(
'\n'+
'\n')
362 print "wrote ",writtenWF,
' workflow'+(
's' if (writtenWF!=1)
else ''),
' to ', outFile.name
367 if selected: selected =
map(float,selected)
369 fmt1 =
"%-6s %-35s [1]: %s ..."
370 fmt2 =
" %35s [%d]: %s ..."
371 print "\nfound a total of ", len(self.
workFlows),
' workflows:'
373 print " of which the following", len(selected),
'were selected:'
376 fmt1 =
"%-6s %-35s [1]: %s "
377 fmt2 =
" %35s [%d]: %s"
381 if selected
and float(wf.numId)
not in selected:
continue
382 if extended:
print ''
384 for i
in range(len(N),len(wf.cmds)): N.append(0)
386 wfName, stepNames = wf.nameId.split(
'+',1)
387 for i,s
in enumerate(wf.cmds):
390 print fmt1 % (wf.numId, stepNames, (str(s)+
' ')[:maxLen])
392 print fmt2 % (
' ', i+1, (str(s)+
' ')[:maxLen])
394 print "%-6s %-35s "% (wf.numId, stepNames)
397 for i,n
in enumerate(N):
398 if n:
print n,
'workflows with',i+1,
'steps'
407 keyList = self.workFlowSteps.keys()
411 if pref != prefixIn :
continue
416 num, name, commands, stepList = val
417 nameId = str(num)+
'_'+name
419 print "==> duplicate name found for ", nameId
420 print ' keeping : ', self.
nameList[nameId]
421 print ' ignoring : ', val
425 self.workFlows.append(
WorkFlow(num, name, commands=commands))
429 def prepare(self, useInput=None, refRel='', fromScratch=None):
431 for matrixFile
in self.
files:
432 if self.
what !=
'all' and self.
what not in matrixFile:
433 print "ignoring non-requested file",matrixFile
435 if self.
what ==
'all' and (
'upgrade' in matrixFile):
436 print "ignoring",matrixFile,
"from default matrix"
440 self.
readMatrix(matrixFile, useInput, refRel, fromScratch)
442 print "ERROR reading file:", matrixFile, str(e)
448 print "ERROR creating workflows :", str(e)
452 def show(self, selected=None, extended=True):
455 print '\n',
'-'*80,
'\n'
461 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)