1 from __future__
import print_function
4 from Configuration.PyReleaseValidation.WorkFlow
import WorkFlow
5 from Configuration.PyReleaseValidation.MatrixUtil
import InputInfo
44 'relval_highstats':
'hi-' ,
45 'relval_pileup':
'PU-' ,
46 'relval_generator':
'gen-',
47 'relval_extendedgen':
'genExt-',
48 'relval_production':
'prod-' ,
50 'relval_upgrade':
'upg-',
51 'relval_cleanedupgrade':
'clnupg-',
53 'relval_2017':
'2017-',
54 'relval_2026':
'2026-',
55 'relval_identity':
'id-',
56 'relval_machine':
'mach-',
57 'relval_premix':
'premix-',
61 self.
files = [
'relval_standard' ,
69 'relval_cleanedupgrade',
79 'relval_highstats':
True ,
81 'relval_generator':
True,
82 'relval_extendedgen':
True,
83 'relval_production':
True,
85 'relval_upgrade':
False,
86 'relval_cleanedupgrade':
False,
90 'relval_identity':
False,
91 'relval_machine':
True,
105 for k,v
in step.items():
106 if 'no_exec' in k :
continue 107 if k.lower() ==
'cfg':
110 if k.lower() ==
'input':
117 cmd +=
' ' + k +
' ' +
str(v)
118 return cfg, input, cmd
122 if len(overrides) > 0:
123 copyStep=
merge([overrides]+[step])
128 def readMatrix(self, fileNameIn, useInput=None, refRel=None, fromScratch=None):
132 print(
"processing", fileNameIn)
135 _tmpMod = __import__(
'Configuration.PyReleaseValidation.'+fileNameIn )
136 self.
relvalModule = sys.modules[
'Configuration.PyReleaseValidation.'+fileNameIn]
137 except Exception
as e:
138 print(
"ERROR importing file ", fileNameIn,
str(e))
141 if useInput
is not None:
142 print(
"request for INPUT for ", useInput)
159 fromInput[
float(k)]=0
161 fromInput[
float(i)]=0
164 fromScratch=
map(float,fromScratch)
165 for num
in fromScratch:
176 refRels=refRel.split(
',')
177 if len(refRels)!=len(self.
relvalModule.baseDataSetRelease):
186 [(x,refRel)
for x
in self.
relvalModule.baseDataSetRelease]
193 stepOverrides=wfInfo.overrides
197 if isinstance(wfName, list)
and len(wfName)>1:
198 if len(wfName)>2: wfSuffix = wfName[2]
202 if wfName.strip() ==
'': wfName = stepList[0]
208 if not isinstance(addCom, list): addCom=[addCom]
213 while len(addTo)!=len(stepList):
219 name = name+
'+'+wfKey
220 if len(wfSuffix)>0: name = name+wfSuffix
223 name_for_workflow = name
227 ilevel=fromInput[num]
229 for (stepIr,step)
in enumerate(reversed(stepList)):
231 stepI=(len(stepList)-stepIr)-1
237 testName=
'__'.
join(stepList[0:stepI+1])+
'INPUT' 239 testName=step+
'INPUT' 243 stepList[stepI]=testName
246 for p
in range(stepI):
251 for (stepI,step)
in enumerate(stepList):
257 if stepName
in [
'SKIMD',
'SKIMCOSD',
'SKIMDreHLT']:
262 if len(name) > 0 : name +=
'+' 267 if step+'INPUT' in self.relvalModule.steps.keys(): 268 stepName = step+"INPUT" 269 stepList.remove(step) 270 stepList.insert(stepIndex,stepName) 272 stepNameTmp = stepName
273 if len(wfKey)>0: stepNameTmp = stepNameTmp.replace(
'_'+wfKey,
"")
274 if len(wfSuffix)>0: stepNameTmp = stepNameTmp.replace(wfSuffix,
"")
276 if addCom
and (
not addTo
or addTo[stepIndex]==1):
279 cfg, input, opts = self.
makeCmd(copyStep)
284 msg =
"FATAL ERROR: found both cfg and input for workflow "+
str(num)+
' step '+stepName
293 cmd =
'cmsDriver.py '+cfg+
' '+opts
295 cmd =
'cmsDriver.py step'+
str(stepIndex+1)+
' '+opts
297 cmd+=
' --io %s.io --python %s.py'%(stepName,stepName)
300 if stepIndex
in self.
apply or stepName
in self.
apply:
305 cmd=cmd.replace(
'DQMIO',
'DQM')
306 cmd=cmd.replace(
'--filetype DQM',
'')
308 ranStepList.append(stepName)
310 self.
workFlowSteps[(num,prefix)] = (num, name_for_workflow, commands, ranStepList)
315 def showRaw(self, useInput, refRel=None, fromScratch=None, what='all',step1Only=False,selected=None):
318 selected=
map(float,selected)
319 for matrixFile
in self.
files:
323 if self.
what !=
'all' and not any(
'_'+el
in matrixFile
for el
in self.
what.
split(
",")):
324 print(
"ignoring non-requested file",matrixFile)
328 print(
"ignoring file not used by default (enable with -w)",matrixFile)
332 self.
readMatrix(matrixFile, useInput, refRel, fromScratch)
333 except Exception
as e:
334 print(
"ERROR reading file:", matrixFile,
str(e))
339 dataFileName = matrixFile.replace(
'relval_',
'cmsDriver_')+
'_hlt.txt' 340 outFile = open(dataFileName,
'w')
348 if selected
and not (key[0]
in selected):
351 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 353 wfName,stepNames= name.split(
'+',1)
355 stepNames=stepNames.replace(
'+SKIMCOSD',
'')
356 stepNames=stepNames.replace(
'+SKIMD',
'')
357 if 'HARVEST' in stepNames:
359 exactb=stepNames.index(
'+HARVEST')
360 exacte=stepNames.index(
'+',exactb+1)
if (
'+' in stepNames[exactb+1:])
else (len(stepNames))
361 stepNames=stepNames.replace(stepNames[exactb:exacte],
'')
364 step1,otherSteps = stepNames.split(
'+',1)
366 line =
str(num) +
' ++ '+ wfName
367 if otherSteps
and not step1Only:
368 line +=
' ++ ' +otherSteps.replace(
'+',
',')
372 if not isinstance(commands[0],str):
373 inputInfo=commands[0]
375 for (i,c)
in enumerate(otherSteps.split(
'+')):
377 for p
in range(len(indexAndSteps),i+2):
378 indexAndSteps.append(set())
379 indexAndSteps[i+1].
add((c,commands[i+1]))
383 if step1Only:
continue 384 line +=
' ++ REALDATA: '+inputInfo.dataSet
385 if inputInfo.run!=[]: line +=
', RUN:'+
'|'.
join(
map(str,inputInfo.run))
386 line +=
', FILES: ' +
str(inputInfo.files)
387 line +=
', EVENTS: '+
str(inputInfo.events)
388 if inputInfo.label!=
'':
389 line +=
', LABEL: ' +inputInfo.label
390 line +=
', LOCATION:'+inputInfo.location
393 line +=
' @@@ '+commands[0]
395 line=line.replace(
'DQMIO',
'DQM')
397 outFile.write(line+
'\n')
400 outFile.write(
'\n'+
'\n')
401 if step1Only:
continue 403 for (index,s)
in enumerate(indexAndSteps):
404 for (stepName,cmd)
in s:
406 if 'dasquery.log' in cmd:
continue 407 line =
'STEP%d ++ '%(stepIndex,) +stepName +
' @@@ '+cmd
409 line=line.replace(
'DQMIO',
'DQM')
410 outFile.write(line+
'\n')
411 outFile.write(
'\n'+
'\n')
413 print(
"wrote ",writtenWF,
' workflow'+(
's' if (writtenWF!=1)
else ''),
' to ', outFile.name)
419 if 'cms/caf/cms' in os.environ[
'CMS_PATH']:
424 if isinstance(workflow.cmds[0], InputInfo):
425 if cafVeto
and (workflow.cmds[0].location ==
'CAF' and not onCAF):
427 workflows.append(workflow)
432 if selected: selected = list(
map(float,selected))
435 fmt1 =
"%-6s %-35s [1]: %s ..." 436 fmt2 =
" %35s [%d]: %s ..." 437 print(
"\nfound a total of ", len(wfs),
' workflows:')
439 print(
" of which the following", len(selected),
'were selected:')
442 fmt1 =
"%-6s %-35s [1]: %s " 443 fmt2 =
" %35s [%d]: %s" 447 if selected
and float(wf.numId)
not in selected:
continue 448 if extended:
print(
'')
450 for i
in range(len(N),len(wf.cmds)): N.append(0)
453 stepNames =
'+'.
join(wf.stepList)
454 for i,s
in enumerate(wf.cmds):
457 print(fmt1 % (wf.numId, stepNames, (
str(s)+
' ')[:maxLen]))
459 print(fmt2 % (
' ', i+1, (
str(s)+
' ')[:maxLen]))
461 print(
"%-6s %-35s "% (wf.numId, stepNames))
464 for i,n
in enumerate(N):
465 if n:
print(n,
'workflows with',i+1,
'steps')
478 if pref != prefixIn :
continue 483 num, name, commands, stepList = val
484 nameId =
str(num)+
'_'+name
486 print(
"==> duplicate name found for ", nameId)
488 print(
' ignoring : ', val)
496 def prepare(self, useInput=None, refRel='', fromScratch=None):
498 for matrixFile
in self.
files:
499 if self.
what !=
'all' and not any(
'_'+el
in matrixFile
for el
in self.
what.
split(
",")):
500 print(
"ignoring non-requested file",matrixFile)
503 print(
"ignoring",matrixFile,
"from default matrix")
507 self.
readMatrix(matrixFile, useInput, refRel, fromScratch)
508 except Exception
as e:
509 print(
"ERROR reading file:", matrixFile,
str(e))
514 except Exception
as e:
515 print(
"ERROR creating workflows :",
str(e))
519 def show(self, selected=None, extended=True, cafVeto=True):
522 print(
'\n',
'-'*80,
'\n')
528 pickle.dump(self.
workFlows, open(
'theMatrix.pkl',
'w') )
revertDqmio
maybe we want too level deep input
def prepare(self, useInput=None, refRel='', fromScratch=None)
bool any(const std::vector< T > &v, const T &what)
def readMatrix(self, fileNameIn, useInput=None, refRel=None, fromScratch=None)
OutputIterator zip(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp)
def makeStep(self, step, overrides)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
def showWorkFlows(self, selected=None, extended=True, cafVeto=True)
def show(self, selected=None, extended=True, cafVeto=True)
def showRaw(self, useInput, refRel=None, fromScratch=None, what='all', step1Only=False, selected=None)
def reset(self, what='all')
def split(sequence, size)
static std::string join(char **cmd)
def createWorkFlows(self, fileNameIn)
def changeRefRelease(steps, listOfPairs)
void add(std::map< std::string, TH1 *> &h, TH1 *hist)
def workFlowsByLocation(self, cafVeto=True)