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-' 60 self.
files = [
'relval_standard' ,
68 'relval_cleanedupgrade',
77 'relval_highstats':
True ,
79 'relval_generator':
True,
80 'relval_extendedgen':
True,
81 'relval_production':
True,
83 'relval_upgrade':
False,
84 'relval_cleanedupgrade':
False,
88 'relval_identity':
False,
89 'relval_machine':
True,
102 for k,v
in step.items():
103 if 'no_exec' in k :
continue 104 if k.lower() ==
'cfg':
107 if k.lower() ==
'input':
114 cmd +=
' ' + k +
' ' +
str(v)
115 return cfg, input, cmd
119 if len(overrides) > 0:
120 copyStep=
merge([overrides]+[step])
125 def readMatrix(self, fileNameIn, useInput=None, refRel=None, fromScratch=None):
129 print(
"processing", fileNameIn)
132 _tmpMod = __import__(
'Configuration.PyReleaseValidation.'+fileNameIn )
133 self.
relvalModule = sys.modules[
'Configuration.PyReleaseValidation.'+fileNameIn]
134 except Exception
as e:
135 print(
"ERROR importing file ", fileNameIn,
str(e))
138 if useInput
is not None:
139 print(
"request for INPUT for ", useInput)
156 fromInput[
float(k)]=0
158 fromInput[
float(i)]=0
161 fromScratch=
map(float,fromScratch)
162 for num
in fromScratch:
173 refRels=refRel.split(
',')
174 if len(refRels)!=len(self.
relvalModule.baseDataSetRelease):
183 [(x,refRel)
for x
in self.
relvalModule.baseDataSetRelease]
191 stepOverrides=wfInfo.overrides
195 if isinstance(wfName, list)
and len(wfName)>1:
196 if len(wfName)>2: wfSuffix = wfName[2]
200 if wfName.strip() ==
'': wfName = stepList[0]
206 if not isinstance(addCom, list): addCom=[addCom]
211 while len(addTo)!=len(stepList):
217 name = name+
'+'+wfKey
218 if len(wfSuffix)>0: name = name+wfSuffix
224 ilevel=fromInput[num]
226 for (stepIr,step)
in enumerate(reversed(stepList)):
228 stepI=(len(stepList)-stepIr)-1
234 testName=
'__'.
join(stepList[0:stepI+1])+
'INPUT' 236 testName=step+
'INPUT' 240 stepList[stepI]=testName
243 for p
in range(stepI):
249 for (stepI,step)
in enumerate(stepList):
255 if stepName
in [
'SKIMD',
'SKIMCOSD',
'SKIMDreHLT']:
260 if len(name) > 0 : name +=
'+' 265 if step+'INPUT' in self.relvalModule.steps.keys(): 266 stepName = step+"INPUT" 267 stepList.remove(step) 268 stepList.insert(stepIndex,stepName) 270 stepNameTmp = stepName
271 if len(wfKey)>0: stepNameTmp = stepNameTmp.replace(
'_'+wfKey,
"")
272 if len(wfSuffix)>0: stepNameTmp = stepNameTmp.replace(wfSuffix,
"")
274 if addCom
and (
not addTo
or addTo[stepIndex]==1):
277 cfg, input, opts = self.
makeCmd(copyStep)
282 msg =
"FATAL ERROR: found both cfg and input for workflow "+
str(num)+
' step '+stepName
291 cmd =
'cmsDriver.py '+cfg+
' '+opts
293 cmd =
'cmsDriver.py step'+
str(stepIndex+1)+
' '+opts
295 cmd+=
' --io %s.io --python %s.py'%(stepName,stepName)
298 if stepIndex
in self.
apply or stepName
in self.
apply:
303 cmd=cmd.replace(
'DQMIO',
'DQM')
304 cmd=cmd.replace(
'--filetype DQM',
'')
306 ranStepList.append(stepName)
309 self.
workFlowSteps[(num,prefix)] = (num, name, commands, ranStepList)
314 def showRaw(self, useInput, refRel=None, fromScratch=None, what='all',step1Only=False,selected=None):
317 selected=
map(float,selected)
318 for matrixFile
in self.
files:
322 if self.
what !=
'all' and not any(
'_'+el
in matrixFile
for el
in self.
what.
split(
",")):
323 print(
"ignoring non-requested file",matrixFile)
327 print(
"ignoring file not used by default (enable with -w)",matrixFile)
331 self.
readMatrix(matrixFile, useInput, refRel, fromScratch)
332 except Exception
as e:
333 print(
"ERROR reading file:", matrixFile,
str(e))
338 dataFileName = matrixFile.replace(
'relval_',
'cmsDriver_')+
'_hlt.txt' 339 outFile = open(dataFileName,
'w')
347 if selected
and not (key[0]
in selected):
350 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)
452 wfName, stepNames = wf.nameId.split(
'+',1)
453 for i,s
in enumerate(wf.cmds):
456 print(fmt1 % (wf.numId, stepNames, (
str(s)+
' ')[:maxLen]))
458 print(fmt2 % (
' ', i+1, (
str(s)+
' ')[:maxLen]))
460 print(
"%-6s %-35s "% (wf.numId, stepNames))
463 for i,n
in enumerate(N):
464 if n:
print(n,
'workflows with',i+1,
'steps')
477 if pref != prefixIn :
continue 482 num, name, commands, stepList = val
483 nameId =
str(num)+
'_'+name
485 print(
"==> duplicate name found for ", nameId)
487 print(
' ignoring : ', val)
495 def prepare(self, useInput=None, refRel='', fromScratch=None):
497 for matrixFile
in self.
files:
498 if self.
what !=
'all' and not any(
'_'+el
in matrixFile
for el
in self.
what.
split(
",")):
499 print(
"ignoring non-requested file",matrixFile)
502 print(
"ignoring",matrixFile,
"from default matrix")
506 self.
readMatrix(matrixFile, useInput, refRel, fromScratch)
507 except Exception
as e:
508 print(
"ERROR reading file:", matrixFile,
str(e))
513 except Exception
as e:
514 print(
"ERROR creating workflows :",
str(e))
518 def show(self, selected=None, extended=True, cafVeto=True):
521 print(
'\n',
'-'*80,
'\n')
527 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)