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]
194 stepOverrides=wfInfo.overrides
198 if isinstance(wfName, list)
and len(wfName)>1:
199 if len(wfName)>2: wfSuffix = wfName[2]
203 if wfName.strip() ==
'': wfName = stepList[0]
209 if not isinstance(addCom, list): addCom=[addCom]
214 while len(addTo)!=len(stepList):
220 name = name+
'+'+wfKey
221 if len(wfSuffix)>0: name = name+wfSuffix
224 name_for_workflow = name
228 ilevel=fromInput[num]
230 for (stepIr,step)
in enumerate(reversed(stepList)):
232 stepI=(len(stepList)-stepIr)-1
238 testName=
'__'.
join(stepList[0:stepI+1])+
'INPUT' 240 testName=step+
'INPUT' 244 stepList[stepI]=testName
247 for p
in range(stepI):
253 for (stepI,step)
in enumerate(stepList):
259 if stepName
in [
'SKIMD',
'SKIMCOSD',
'SKIMDreHLT']:
264 if len(name) > 0 : name +=
'+' 269 if step+'INPUT' in self.relvalModule.steps.keys(): 270 stepName = step+"INPUT" 271 stepList.remove(step) 272 stepList.insert(stepIndex,stepName) 274 stepNameTmp = stepName
275 if len(wfKey)>0: stepNameTmp = stepNameTmp.replace(
'_'+wfKey,
"")
276 if len(wfSuffix)>0: stepNameTmp = stepNameTmp.replace(wfSuffix,
"")
278 if addCom
and (
not addTo
or addTo[stepIndex]==1):
281 cfg, input, opts = self.
makeCmd(copyStep)
286 msg =
"FATAL ERROR: found both cfg and input for workflow "+
str(num)+
' step '+stepName
295 cmd =
'cmsDriver.py '+cfg+
' '+opts
297 cmd =
'cmsDriver.py step'+
str(stepIndex+1)+
' '+opts
299 cmd+=
' --io %s.io --python %s.py'%(stepName,stepName)
302 if stepIndex
in self.
apply or stepName
in self.
apply:
307 cmd=cmd.replace(
'DQMIO',
'DQM')
308 cmd=cmd.replace(
'--filetype DQM',
'')
310 ranStepList.append(stepName)
312 self.
workFlowSteps[(num,prefix)] = (num, name_for_workflow, commands, ranStepList)
317 def showRaw(self, useInput, refRel=None, fromScratch=None, what='all',step1Only=False,selected=None):
320 selected=
map(float,selected)
321 for matrixFile
in self.
files:
325 if self.
what !=
'all' and not any(
'_'+el
in matrixFile
for el
in self.
what.
split(
",")):
326 print(
"ignoring non-requested file",matrixFile)
330 print(
"ignoring file not used by default (enable with -w)",matrixFile)
334 self.
readMatrix(matrixFile, useInput, refRel, fromScratch)
335 except Exception
as e:
336 print(
"ERROR reading file:", matrixFile,
str(e))
341 dataFileName = matrixFile.replace(
'relval_',
'cmsDriver_')+
'_hlt.txt' 342 outFile = open(dataFileName,
'w')
350 if selected
and not (key[0]
in selected):
353 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 355 wfName,stepNames= name.split(
'+',1)
357 stepNames=stepNames.replace(
'+SKIMCOSD',
'')
358 stepNames=stepNames.replace(
'+SKIMD',
'')
359 if 'HARVEST' in stepNames:
361 exactb=stepNames.index(
'+HARVEST')
362 exacte=stepNames.index(
'+',exactb+1)
if (
'+' in stepNames[exactb+1:])
else (len(stepNames))
363 stepNames=stepNames.replace(stepNames[exactb:exacte],
'')
366 step1,otherSteps = stepNames.split(
'+',1)
368 line =
str(num) +
' ++ '+ wfName
369 if otherSteps
and not step1Only:
370 line +=
' ++ ' +otherSteps.replace(
'+',
',')
374 if not isinstance(commands[0],str):
375 inputInfo=commands[0]
377 for (i,c)
in enumerate(otherSteps.split(
'+')):
379 for p
in range(len(indexAndSteps),i+2):
380 indexAndSteps.append(set())
381 indexAndSteps[i+1].
add((c,commands[i+1]))
385 if step1Only:
continue 386 line +=
' ++ REALDATA: '+inputInfo.dataSet
387 if inputInfo.run!=[]: line +=
', RUN:'+
'|'.
join(
map(str,inputInfo.run))
388 line +=
', FILES: ' +
str(inputInfo.files)
389 line +=
', EVENTS: '+
str(inputInfo.events)
390 if inputInfo.label!=
'':
391 line +=
', LABEL: ' +inputInfo.label
392 line +=
', LOCATION:'+inputInfo.location
395 line +=
' @@@ '+commands[0]
397 line=line.replace(
'DQMIO',
'DQM')
399 outFile.write(line+
'\n')
402 outFile.write(
'\n'+
'\n')
403 if step1Only:
continue 405 for (index,s)
in enumerate(indexAndSteps):
406 for (stepName,cmd)
in s:
408 if 'dasquery.log' in cmd:
continue 409 line =
'STEP%d ++ '%(stepIndex,) +stepName +
' @@@ '+cmd
411 line=line.replace(
'DQMIO',
'DQM')
412 outFile.write(line+
'\n')
413 outFile.write(
'\n'+
'\n')
415 print(
"wrote ",writtenWF,
' workflow'+(
's' if (writtenWF!=1)
else ''),
' to ', outFile.name)
421 if 'cms/caf/cms' in os.environ[
'CMS_PATH']:
426 if isinstance(workflow.cmds[0], InputInfo):
427 if cafVeto
and (workflow.cmds[0].location ==
'CAF' and not onCAF):
429 workflows.append(workflow)
434 if selected: selected = list(
map(float,selected))
437 fmt1 =
"%-6s %-35s [1]: %s ..." 438 fmt2 =
" %35s [%d]: %s ..." 439 print(
"\nfound a total of ", len(wfs),
' workflows:')
441 print(
" of which the following", len(selected),
'were selected:')
444 fmt1 =
"%-6s %-35s [1]: %s " 445 fmt2 =
" %35s [%d]: %s" 449 if selected
and float(wf.numId)
not in selected:
continue 450 if extended:
print(
'')
452 for i
in range(len(N),len(wf.cmds)): N.append(0)
455 stepNames =
'+'.
join(wf.stepList)
456 for i,s
in enumerate(wf.cmds):
459 print(fmt1 % (wf.numId, stepNames, (
str(s)+
' ')[:maxLen]))
461 print(fmt2 % (
' ', i+1, (
str(s)+
' ')[:maxLen]))
463 print(
"%-6s %-35s "% (wf.numId, stepNames))
466 for i,n
in enumerate(N):
467 if n:
print(n,
'workflows with',i+1,
'steps')
480 if pref != prefixIn :
continue 485 num, name, commands, stepList = val
486 nameId =
str(num)+
'_'+name
488 print(
"==> duplicate name found for ", nameId)
490 print(
' ignoring : ', val)
498 def prepare(self, useInput=None, refRel='', fromScratch=None):
500 for matrixFile
in self.
files:
501 if self.
what !=
'all' and not any(
'_'+el
in matrixFile
for el
in self.
what.
split(
",")):
502 print(
"ignoring non-requested file",matrixFile)
505 print(
"ignoring",matrixFile,
"from default matrix")
509 self.
readMatrix(matrixFile, useInput, refRel, fromScratch)
510 except Exception
as e:
511 print(
"ERROR reading file:", matrixFile,
str(e))
516 except Exception
as e:
517 print(
"ERROR creating workflows :",
str(e))
521 def show(self, selected=None, extended=True, cafVeto=True):
524 print(
'\n',
'-'*80,
'\n')
530 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)