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-',
58 'relval_nano':
'nano-',
59 'relval_data_highstats':
'data-' 62 self.
files = [
'relval_standard' ,
70 'relval_cleanedupgrade',
78 'relval_data_highstats' 81 'relval_highstats':
True ,
83 'relval_generator':
True,
84 'relval_extendedgen':
True,
85 'relval_production':
True,
87 'relval_upgrade':
False,
88 'relval_cleanedupgrade':
False,
92 'relval_identity':
False,
93 'relval_machine':
True,
96 'relval_data_highstats':
False 108 for k,v
in step.items():
109 if 'no_exec' in k :
continue 110 if k.lower() ==
'cfg':
113 if k.lower() ==
'input':
120 cmd +=
' ' + k +
' ' +
str(v)
121 return cfg, input, cmd
125 if len(overrides) > 0:
126 copyStep=
merge([overrides]+[step])
131 def readMatrix(self, fileNameIn, useInput=None, refRel=None, fromScratch=None):
135 print(
"processing", fileNameIn)
138 _tmpMod = __import__(
'Configuration.PyReleaseValidation.'+fileNameIn )
139 self.
relvalModule = sys.modules[
'Configuration.PyReleaseValidation.'+fileNameIn]
140 except Exception
as e:
141 print(
"ERROR importing file ", fileNameIn,
str(e))
144 if useInput
is not None:
145 print(
"request for INPUT for ", useInput)
162 fromInput[
float(k)]=0
164 fromInput[
float(i)]=0
167 fromScratch=
map(float,fromScratch)
168 for num
in fromScratch:
179 refRels=refRel.split(
',')
180 if len(refRels)!=len(self.
relvalModule.baseDataSetRelease):
189 [(x,refRel)
for x
in self.
relvalModule.baseDataSetRelease]
196 stepOverrides=wfInfo.overrides
200 if isinstance(wfName, list)
and len(wfName)>1:
201 if len(wfName)>2: wfSuffix = wfName[2]
205 if wfName.strip() ==
'': wfName = stepList[0]
211 if not isinstance(addCom, list): addCom=[addCom]
216 while len(addTo)!=len(stepList):
222 name = name+
'+'+wfKey
223 if len(wfSuffix)>0: name = name+wfSuffix
226 name_for_workflow = name
230 ilevel=fromInput[num]
232 for (stepIr,step)
in enumerate(reversed(stepList)):
234 stepI=(len(stepList)-stepIr)-1
240 testName=
'__'.
join(stepList[0:stepI+1])+
'INPUT' 242 testName=step+
'INPUT' 246 stepList[stepI]=testName
249 for p
in range(stepI):
254 for (stepI,step)
in enumerate(stepList):
260 if stepName
in [
'SKIMD',
'SKIMCOSD',
'SKIMDreHLT']:
265 if len(name) > 0 : name +=
'+' 270 if step+'INPUT' in self.relvalModule.steps.keys(): 271 stepName = step+"INPUT" 272 stepList.remove(step) 273 stepList.insert(stepIndex,stepName) 275 stepNameTmp = stepName
276 if len(wfKey)>0: stepNameTmp = stepNameTmp.replace(
'_'+wfKey,
"")
277 if len(wfSuffix)>0: stepNameTmp = stepNameTmp.replace(wfSuffix,
"")
279 if addCom
and (
not addTo
or addTo[stepIndex]==1):
282 cfg, input, opts = self.
makeCmd(copyStep)
287 msg =
"FATAL ERROR: found both cfg and input for workflow "+
str(num)+
' step '+stepName
296 cmd =
'cmsDriver.py '+cfg+
' '+opts
298 cmd =
'cmsDriver.py step'+
str(stepIndex+1)+
' '+opts
300 cmd+=
' --io %s.io --python %s.py'%(stepName,stepName)
303 if stepIndex
in self.
apply or stepName
in self.
apply:
308 cmd=cmd.replace(
'DQMIO',
'DQM')
309 cmd=cmd.replace(
'--filetype DQM',
'')
311 ranStepList.append(stepName)
313 self.
workFlowSteps[(num,prefix)] = (num, name_for_workflow, commands, ranStepList)
318 def showRaw(self, useInput, refRel=None, fromScratch=None, what='all',step1Only=False,selected=None):
321 selected=
map(float,selected)
322 for matrixFile
in self.
files:
326 if self.
what !=
'all' and not any(
'_'+el
in matrixFile
for el
in self.
what.
split(
",")):
327 print(
"ignoring non-requested file",matrixFile)
331 print(
"ignoring file not used by default (enable with -w)",matrixFile)
335 self.
readMatrix(matrixFile, useInput, refRel, fromScratch)
336 except Exception
as e:
337 print(
"ERROR reading file:", matrixFile,
str(e))
342 dataFileName = matrixFile.replace(
'relval_',
'cmsDriver_')+
'_hlt.txt' 343 outFile = open(dataFileName,
'w')
351 if selected
and not (key[0]
in selected):
354 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 356 wfName,stepNames= name.split(
'+',1)
358 stepNames=stepNames.replace(
'+SKIMCOSD',
'')
359 stepNames=stepNames.replace(
'+SKIMD',
'')
360 if 'HARVEST' in stepNames:
362 exactb=stepNames.index(
'+HARVEST')
363 exacte=stepNames.index(
'+',exactb+1)
if (
'+' in stepNames[exactb+1:])
else (len(stepNames))
364 stepNames=stepNames.replace(stepNames[exactb:exacte],
'')
367 step1,otherSteps = stepNames.split(
'+',1)
369 line =
str(num) +
' ++ '+ wfName
370 if otherSteps
and not step1Only:
371 line +=
' ++ ' +otherSteps.replace(
'+',
',')
375 if not isinstance(commands[0],str):
376 inputInfo=commands[0]
378 for (i,c)
in enumerate(otherSteps.split(
'+')):
380 for p
in range(len(indexAndSteps),i+2):
381 indexAndSteps.append(set())
382 indexAndSteps[i+1].
add((c,commands[i+1]))
386 if step1Only:
continue 387 line +=
' ++ REALDATA: '+inputInfo.dataSet
388 if inputInfo.run!=[]: line +=
', RUN:'+
'|'.
join(
map(str,inputInfo.run))
389 line +=
', FILES: ' +
str(inputInfo.files)
390 line +=
', EVENTS: '+
str(inputInfo.events)
391 if inputInfo.label!=
'':
392 line +=
', LABEL: ' +inputInfo.label
393 line +=
', LOCATION:'+inputInfo.location
396 line +=
' @@@ '+commands[0]
398 line=line.replace(
'DQMIO',
'DQM')
400 outFile.write(line+
'\n')
403 outFile.write(
'\n'+
'\n')
404 if step1Only:
continue 406 for (index,s)
in enumerate(indexAndSteps):
407 for (stepName,cmd)
in s:
409 if 'dasquery.log' in cmd:
continue 410 line =
'STEP%d ++ '%(stepIndex,) +stepName +
' @@@ '+cmd
412 line=line.replace(
'DQMIO',
'DQM')
413 outFile.write(line+
'\n')
414 outFile.write(
'\n'+
'\n')
416 print(
"wrote ",writtenWF,
' workflow'+(
's' if (writtenWF!=1)
else ''),
' to ', outFile.name)
422 if 'cms/caf/cms' in os.environ[
'CMS_PATH']:
427 if isinstance(workflow.cmds[0], InputInfo):
428 if cafVeto
and (workflow.cmds[0].location ==
'CAF' and not onCAF):
430 workflows.append(workflow)
435 if selected: selected = list(
map(float,selected))
438 fmt1 =
"%-6s %-35s [1]: %s ..." 439 fmt2 =
" %35s [%d]: %s ..." 440 print(
"\nfound a total of ", len(wfs),
' workflows:')
442 print(
" of which the following", len(selected),
'were selected:')
445 fmt1 =
"%-6s %-35s [1]: %s " 446 fmt2 =
" %35s [%d]: %s" 450 if selected
and float(wf.numId)
not in selected:
continue 451 if extended:
print(
'')
453 for i
in range(len(N),len(wf.cmds)): N.append(0)
456 stepNames =
'+'.
join(wf.stepList)
457 for i,s
in enumerate(wf.cmds):
460 print(fmt1 % (wf.numId, stepNames, (
str(s)+
' ')[:maxLen]))
462 print(fmt2 % (
' ', i+1, (
str(s)+
' ')[:maxLen]))
464 print(
"%-6s %-35s "% (wf.numId, stepNames))
467 for i,n
in enumerate(N):
468 if n:
print(n,
'workflows with',i+1,
'steps')
481 if pref != prefixIn :
continue 486 num, name, commands, stepList = val
487 nameId =
str(num)+
'_'+name
489 print(
"==> duplicate name found for ", nameId)
491 print(
' ignoring : ', val)
499 def prepare(self, useInput=None, refRel='', fromScratch=None):
501 for matrixFile
in self.
files:
502 if self.
what !=
'all' and not any(
'_'+el
in matrixFile
for el
in self.
what.
split(
",")):
503 print(
"ignoring non-requested file",matrixFile)
506 print(
"ignoring",matrixFile,
"from default matrix")
510 self.
readMatrix(matrixFile, useInput, refRel, fromScratch)
511 except Exception
as e:
512 print(
"ERROR reading file:", matrixFile,
str(e))
517 except Exception
as e:
518 print(
"ERROR creating workflows :",
str(e))
522 def show(self, selected=None, extended=True, cafVeto=True):
525 print(
'\n',
'-'*80,
'\n')
531 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)
ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE constexpr float zip(ConstView const &tracks, int32_t i)
def readMatrix(self, fileNameIn, useInput=None, refRel=None, fromScratch=None)
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)