4 from Configuration.PyReleaseValidation.WorkFlow
import WorkFlow
40 'relval_highstats':
'hi-' ,
41 'relval_pileup':
'PU-' ,
42 'relval_generator':
'gen-' ,
43 'relval_production':
'prod-' ,
45 'relval_identity':
'id-'
48 self.
files = [
'relval_standard' ,
66 for k,v
in step.items():
67 if 'no_exec' in k :
continue
68 if k.lower() ==
'cfg':
71 if k.lower() ==
'input':
78 cmd +=
' ' + k +
' ' + str(v)
79 return cfg, input, cmd
81 def readMatrix(self, fileNameIn, useInput=None, refRel=None, fromScratch=None):
85 print "processing ", fileNameIn
88 _tmpMod = __import__(
'Configuration.PyReleaseValidation.'+fileNameIn )
91 print "ERROR importing file ", fileNameIn, str(e)
94 print "request for INPUT for ", useInput
104 for k
in self.relvalModule.workflows.keys():
105 fromInput[float(k)]=int(il)
107 fromInput[float(ik)]=int(il)
110 for k
in self.relvalModule.workflows.keys():
111 fromInput[float(k)]=0
113 fromInput[float(i)]=0
116 fromScratch=
map(float,fromScratch)
117 for num
in fromScratch:
123 self.relvalModule.steps.overwrite(p)
128 refRels=refRel.split(
',')
129 if len(refRels)!=len(self.relvalModule.baseDataSetRelease):
131 self.relvalModule.changeRefRelease(
132 self.relvalModule.steps,
133 zip(self.relvalModule.baseDataSetRelease,refRels)
136 self.relvalModule.changeRefRelease(
137 self.relvalModule.steps,
138 [(x,refRel)
for x
in self.relvalModule.baseDataSetRelease]
142 for num, wfInfo
in self.relvalModule.workflows.items():
147 if wfName.strip() ==
'': wfName = stepList[0]
153 if not type(addCom)==list: addCom=[addCom]
158 while len(addTo)!=len(stepList):
167 ilevel=fromInput[num]
169 for (stepIr,step)
in enumerate(reversed(stepList)):
171 stepI=(len(stepList)-stepIr)-1
177 testName=
'__'.
join(stepList[0:stepI+1])+
'INPUT'
179 testName=step+
'INPUT'
181 if testName
in self.relvalModule.steps.keys():
183 stepList[stepI]=testName
186 for p
in range(stepI):
192 for (stepI,step)
in enumerate(stepList):
196 if stepName
in [
'HARVEST',
'HARVESTD',
'HARVESTDreHLT',
'RECODFROMRAWRECO',
'SKIMD',
'SKIMCOSD',
'SKIMDreHLT']:
201 if len(name) > 0 : name +=
'+'
206 if step+'INPUT' in self.relvalModule.steps.keys():
207 stepName = step+"INPUT"
208 stepList.remove(step)
209 stepList.insert(stepIndex,stepName)
213 if addCom
and (
not addTo
or addTo[stepIndex]==1):
215 copyStep=
merge(addCom+[self.relvalModule.steps[stepName]])
216 cfg, input, opts = self.
makeCmd(copyStep)
218 cfg, input, opts = self.
makeCmd(self.relvalModule.steps[stepName])
221 msg =
"FATAL ERROR: found both cfg and input for workflow "+str(num)+
' step '+stepName
228 cmd =
'cmsDriver.py '+cfg+
' '+opts
230 cmd =
'cmsDriver.py step'+str(stepIndex+1)+
' '+opts
232 cmd+=
' --io %s.io --python %s.py'%(stepName,stepName)
236 cmd=cmd.replace(
'DQMROOT',
'DQM')
237 cmd=cmd.replace(
'--filetype DQM',
'')
239 ranStepList.append(stepName)
242 self.
workFlowSteps[(num,prefix)] = (num, name, commands, ranStepList)
247 def showRaw(self, useInput, refRel=None, fromScratch=None, what='all',step1Only=False,selected=None):
250 selected=
map(float,selected)
251 for matrixFile
in self.
files:
255 if self.
what !=
'all' and self.
what not in matrixFile:
256 print "ignoring non-requested file",matrixFile
260 self.
readMatrix(matrixFile, useInput, refRel, fromScratch)
262 print "ERROR reading file:", matrixFile, str(e)
267 dataFileName = matrixFile.replace(
'relval_',
'cmsDriver_')+
'_hlt.txt'
268 outFile = open(dataFileName,
'w')
270 print "found ", len(self.workFlowSteps.keys()),
' workflows for ', dataFileName
271 ids = self.workFlowSteps.keys()
277 if selected
and not (key[0]
in selected):
280 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
283 wfName,stepNames= name.split(
'+',1)
285 stepNames=stepNames.replace(
'+RECODFROMRAWRECO',
'')
286 stepNames=stepNames.replace(
'+SKIMCOSD',
'')
287 stepNames=stepNames.replace(
'+SKIMD',
'')
288 if 'HARVEST' in stepNames:
290 exactb=stepNames.index(
'+HARVEST')
291 exacte=stepNames.index(
'+',exactb+1)
if (
'+' in stepNames[exactb+1:])
else (len(stepNames))
292 stepNames=stepNames.replace(stepNames[exactb:exacte],
'')
295 step1,otherSteps = stepNames.split(
'+',1)
297 line = str(num) +
' ++ '+ wfName
298 if otherSteps
and not step1Only:
299 line +=
' ++ ' +otherSteps.replace(
'+',
',')
303 if not isinstance(commands[0],str):
304 inputInfo=commands[0]
306 for (i,c)
in enumerate(otherSteps.split(
'+')):
308 for p
in range(len(indexAndSteps),i+2):
309 indexAndSteps.append(
set())
310 indexAndSteps[i+1].
add((c,commands[i+1]))
314 if step1Only:
continue
315 line +=
' ++ REALDATA: '+inputInfo.dataSet
316 if inputInfo.run!=[]: line +=
', RUN:'+
'|'.
join(
map(str,inputInfo.run))
317 line +=
', FILES: ' +str(inputInfo.files)
318 line +=
', EVENTS: '+str(inputInfo.events)
319 if inputInfo.label!=
'':
320 line +=
', LABEL: ' +inputInfo.label
321 line +=
', LOCATION:'+inputInfo.location
324 line +=
' @@@ '+commands[0]
325 line=line.replace(
'DQMROOT',
'DQM')
327 outFile.write(line+
'\n')
330 outFile.write(
'\n'+
'\n')
331 if step1Only:
continue
333 for (index,s)
in enumerate(indexAndSteps):
334 for (stepName,cmd)
in s:
336 if 'dasquery.log' in cmd:
continue
337 line =
'STEP%d ++ '%(stepIndex,) +stepName +
' @@@ '+cmd
338 line=line.replace(
'DQMROOT',
'DQM')
339 outFile.write(line+
'\n')
340 outFile.write(
'\n'+
'\n')
342 print "wrote ",writtenWF,
' workflow'+(
's' if (writtenWF!=1)
else ''),
' to ', outFile.name
347 if selected: selected =
map(float,selected)
349 fmt1 =
"%-6s %-35s [1]: %s ..."
350 fmt2 =
" %35s [%d]: %s ..."
351 print "\nfound a total of ", len(self.
workFlows),
' workflows:'
353 print " of which the following", len(selected),
'were selected:'
356 fmt1 =
"%-6s %-35s [1]: %s "
357 fmt2 =
" %35s [%d]: %s"
361 if selected
and float(wf.numId)
not in selected:
continue
362 if extended:
print ''
364 for i
in range(len(N),len(wf.cmds)): N.append(0)
366 wfName, stepNames = wf.nameId.split(
'+',1)
367 for i,s
in enumerate(wf.cmds):
370 print fmt1 % (wf.numId, stepNames, (str(s)+
' ')[:maxLen])
372 print fmt2 % (
' ', i+1, (str(s)+
' ')[:maxLen])
374 print "%-6s %-35s "% (wf.numId, stepNames)
377 for i,n
in enumerate(N):
378 if n:
print n,
'workflows with',i+1,
'steps'
387 keyList = self.workFlowSteps.keys()
391 if pref != prefixIn :
continue
396 num, name, commands, stepList = val
397 nameId = str(num)+
'_'+name
399 print "==> duplicate name found for ", nameId
400 print ' keeping : ', self.
nameList[nameId]
401 print ' ignoring : ', val
405 self.workFlows.append(
WorkFlow(num, name, commands=commands))
409 def prepare(self, useInput=None, refRel='', fromScratch=None):
411 for matrixFile
in self.
files:
412 if self.
what !=
'all' and self.
what not in matrixFile:
413 print "ignoring non-requested file",matrixFile
417 self.
readMatrix(matrixFile, useInput, refRel, fromScratch)
419 print "ERROR reading file:", matrixFile, str(e)
425 print "ERROR creating workflows :", str(e)
429 def show(self, selected=None, extended=True):
432 print '\n',
'-'*80,
'\n'
438 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)
void set(const std::string &name, int value)
set the flag, with a run-time name