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_2017':
'2017-',
52 'relval_2026':
'2026-',
53 'relval_identity':
'id-',
54 'relval_machine':
'mach-',
55 'relval_unsch':
'unsch-',
56 'relval_premix':
'premix-'
59 self.
files = [
'relval_standard' ,
75 'relval_highstats':
True ,
77 'relval_generator':
True,
78 'relval_extendedgen':
True,
79 'relval_production':
True,
81 'relval_upgrade':
False,
84 'relval_identity':
False,
85 'relval_machine':
True,
99 for k,v
in step.items():
100 if 'no_exec' in k :
continue
101 if k.lower() ==
'cfg':
104 if k.lower() ==
'input':
111 cmd +=
' ' + k +
' ' +
str(v)
112 return cfg, input, cmd
116 if len(overrides) > 0:
117 copyStep=
merge([overrides]+[step])
122 def readMatrix(self, fileNameIn, useInput=None, refRel=None, fromScratch=None):
126 print(
"processing", fileNameIn)
129 _tmpMod = __import__(
'Configuration.PyReleaseValidation.'+fileNameIn )
130 self.
relvalModule = sys.modules[
'Configuration.PyReleaseValidation.'+fileNameIn]
131 except Exception
as e:
132 print(
"ERROR importing file ", fileNameIn,
str(e))
135 if useInput
is not None:
136 print(
"request for INPUT for ", useInput)
153 fromInput[
float(k)]=0
155 fromInput[
float(i)]=0
158 fromScratch=
map(float,fromScratch)
159 for num
in fromScratch:
170 refRels=refRel.split(
',')
171 if len(refRels)!=len(self.
relvalModule.baseDataSetRelease):
180 [(x,refRel)
for x
in self.
relvalModule.baseDataSetRelease]
188 stepOverrides=wfInfo.overrides
190 if wfName.strip() ==
'': wfName = stepList[0]
196 if not isinstance(addCom, list): addCom=[addCom]
201 while len(addTo)!=len(stepList):
210 ilevel=fromInput[num]
212 for (stepIr,step)
in enumerate(reversed(stepList)):
214 stepI=(len(stepList)-stepIr)-1
220 testName=
'__'.
join(stepList[0:stepI+1])+
'INPUT'
222 testName=step+
'INPUT'
226 stepList[stepI]=testName
229 for p
in range(stepI):
235 for (stepI,step)
in enumerate(stepList):
241 if stepName
in [
'SKIMD',
'SKIMCOSD',
'SKIMDreHLT']:
246 if len(name) > 0 : name +=
'+'
251 if step+'INPUT' in self.relvalModule.steps.keys():
252 stepName = step+"INPUT"
253 stepList.remove(step)
254 stepList.insert(stepIndex,stepName)
257 if addCom
and (
not addTo
or addTo[stepIndex]==1):
260 cfg, input, opts = self.
makeCmd(copyStep)
265 msg =
"FATAL ERROR: found both cfg and input for workflow "+
str(num)+
' step '+stepName
274 cmd =
'cmsDriver.py '+cfg+
' '+opts
276 cmd =
'cmsDriver.py step'+
str(stepIndex+1)+
' '+opts
278 cmd+=
' --io %s.io --python %s.py'%(stepName,stepName)
281 if stepIndex
in self.
apply or stepName
in self.
apply:
286 cmd=cmd.replace(
'DQMIO',
'DQM')
287 cmd=cmd.replace(
'--filetype DQM',
'')
289 ranStepList.append(stepName)
292 self.
workFlowSteps[(num,prefix)] = (num, name, commands, ranStepList)
297 def showRaw(self, useInput, refRel=None, fromScratch=None, what='all',step1Only=False,selected=None):
300 selected=
map(float,selected)
301 for matrixFile
in self.
files:
305 if self.
what !=
'all' and self.
what not in matrixFile:
306 print(
"ignoring non-requested file",matrixFile)
310 print(
"ignoring file not used by default (enable with -w)",matrixFile)
314 self.
readMatrix(matrixFile, useInput, refRel, fromScratch)
315 except Exception
as e:
316 print(
"ERROR reading file:", matrixFile,
str(e))
321 dataFileName = matrixFile.replace(
'relval_',
'cmsDriver_')+
'_hlt.txt'
322 outFile = open(dataFileName,
'w')
330 if selected
and not (key[0]
in selected):
333 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
336 wfName,stepNames= name.split(
'+',1)
338 stepNames=stepNames.replace(
'+SKIMCOSD',
'')
339 stepNames=stepNames.replace(
'+SKIMD',
'')
340 if 'HARVEST' in stepNames:
342 exactb=stepNames.index(
'+HARVEST')
343 exacte=stepNames.index(
'+',exactb+1)
if (
'+' in stepNames[exactb+1:])
else (len(stepNames))
344 stepNames=stepNames.replace(stepNames[exactb:exacte],
'')
347 step1,otherSteps = stepNames.split(
'+',1)
349 line =
str(num) +
' ++ '+ wfName
350 if otherSteps
and not step1Only:
351 line +=
' ++ ' +otherSteps.replace(
'+',
',')
355 if not isinstance(commands[0],str):
356 inputInfo=commands[0]
358 for (i,c)
in enumerate(otherSteps.split(
'+')):
360 for p
in range(len(indexAndSteps),i+2):
361 indexAndSteps.append(set())
362 indexAndSteps[i+1].
add((c,commands[i+1]))
366 if step1Only:
continue
367 line +=
' ++ REALDATA: '+inputInfo.dataSet
368 if inputInfo.run!=[]: line +=
', RUN:'+
'|'.
join(
map(str,inputInfo.run))
369 line +=
', FILES: ' +
str(inputInfo.files)
370 line +=
', EVENTS: '+
str(inputInfo.events)
371 if inputInfo.label!=
'':
372 line +=
', LABEL: ' +inputInfo.label
373 line +=
', LOCATION:'+inputInfo.location
376 line +=
' @@@ '+commands[0]
378 line=line.replace(
'DQMIO',
'DQM')
380 outFile.write(line+
'\n')
383 outFile.write(
'\n'+
'\n')
384 if step1Only:
continue
386 for (index,s)
in enumerate(indexAndSteps):
387 for (stepName,cmd)
in s:
389 if 'dasquery.log' in cmd:
continue
390 line =
'STEP%d ++ '%(stepIndex,) +stepName +
' @@@ '+cmd
392 line=line.replace(
'DQMIO',
'DQM')
393 outFile.write(line+
'\n')
394 outFile.write(
'\n'+
'\n')
396 print(
"wrote ",writtenWF,
' workflow'+(
's' if (writtenWF!=1)
else ''),
' to ', outFile.name)
402 if 'cms/caf/cms' in os.environ[
'CMS_PATH']:
407 if isinstance(workflow.cmds[0], InputInfo):
408 if cafVeto
and (workflow.cmds[0].location ==
'CAF' and not onCAF):
410 workflows.append(workflow)
415 if selected: selected =
list(
map(float,selected))
418 fmt1 =
"%-6s %-35s [1]: %s ..."
419 fmt2 =
" %35s [%d]: %s ..."
420 print(
"\nfound a total of ", len(wfs),
' workflows:')
422 print(
" of which the following", len(selected),
'were selected:')
425 fmt1 =
"%-6s %-35s [1]: %s "
426 fmt2 =
" %35s [%d]: %s"
430 if selected
and float(wf.numId)
not in selected:
continue
431 if extended:
print(
'')
433 for i
in range(len(N),len(wf.cmds)): N.append(0)
435 wfName, stepNames = wf.nameId.split(
'+',1)
436 for i,s
in enumerate(wf.cmds):
439 print(fmt1 % (wf.numId, stepNames, (
str(s)+
' ')[:maxLen]))
441 print(fmt2 % (
' ', i+1, (
str(s)+
' ')[:maxLen]))
443 print(
"%-6s %-35s "% (wf.numId, stepNames))
446 for i,n
in enumerate(N):
447 if n:
print(n,
'workflows with',i+1,
'steps')
460 if pref != prefixIn :
continue
465 num, name, commands, stepList = val
466 nameId =
str(num)+
'_'+name
468 print(
"==> duplicate name found for ", nameId)
470 print(
' ignoring : ', val)
478 def prepare(self, useInput=None, refRel='', fromScratch=None):
480 for matrixFile
in self.
files:
481 if self.
what !=
'all' and self.
what not in matrixFile:
482 print(
"ignoring non-requested file",matrixFile)
485 print(
"ignoring",matrixFile,
"from default matrix")
489 self.
readMatrix(matrixFile, useInput, refRel, fromScratch)
490 except Exception
as e:
491 print(
"ERROR reading file:", matrixFile,
str(e))
496 except Exception
as e:
497 print(
"ERROR creating workflows :",
str(e))
501 def show(self, selected=None, extended=True, cafVeto=True):
504 print(
'\n',
'-'*80,
'\n')
510 pickle.dump(self.
workFlows, open(
'theMatrix.pkl',
'w') )