CMS 3D CMS Logo

runTheMatrix.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 from __future__ import print_function
3 import sys
4 
5 from Configuration.PyReleaseValidation.MatrixReader import MatrixReader
6 from Configuration.PyReleaseValidation.MatrixRunner import MatrixRunner
7 from Configuration.PyReleaseValidation.MatrixInjector import MatrixInjector,performInjectionOptionTest
8 
9 # ================================================================================
10 
11 def showRaw(opt):
12 
13  mrd = MatrixReader(opt)
14  mrd.showRaw(opt.useInput, opt.refRel, opt.fromScratch, opt.raw, opt.step1Only, selected=opt.testList)
15 
16  return 0
17 
18 # ================================================================================
19 
20 def runSelected(opt):
21 
22  mrd = MatrixReader(opt)
23  mrd.prepare(opt.useInput, opt.refRel, opt.fromScratch)
24 
25  # test for wrong input workflows
26  if opt.testList:
27  definedSet = set([dwf.numId for dwf in mrd.workFlows])
28  testSet = set(opt.testList)
29  undefSet = testSet - definedSet
30  if len(undefSet)>0: raise ValueError('Undefined workflows: '+', '.join(map(str,list(undefSet))))
31 
32  ret = 0
33  if opt.show:
34  mrd.show(opt.testList, opt.extended, opt.cafVeto)
35  if opt.testList : print('testListected items:', opt.testList)
36  else:
37  mRunnerHi = MatrixRunner(mrd.workFlows, opt.nProcs, opt.nThreads)
38  ret = mRunnerHi.runTests(opt)
39 
40  if opt.wmcontrol:
41  if ret!=0:
42  print('Cannot go on with wmagent injection with failing workflows')
43  else:
44  wfInjector = MatrixInjector(opt,mode=opt.wmcontrol,options=opt.wmoptions)
45  ret= wfInjector.prepare(mrd,
46  mRunnerHi.runDirs)
47  if ret==0:
48  wfInjector.upload()
49  wfInjector.submit()
50  return ret
51 
52 # ================================================================================
53 
54 if __name__ == '__main__':
55 
56  #this can get out of here
57  predefinedSet={
58  'limited' : [5.1, #FastSim ttbar
59  7.3, #CosmicsSPLoose_UP17
60  8, #BH/Cosmic MC
61  25, #MC ttbar
62  4.22, #cosmic data
63  4.53, #run1 data + miniAOD
64  9.0, #Higgs200 charged taus
65  1000, #data+prompt
66  1001, #data+express
67  101.0, #SingleElectron120E120EHCAL
68  136.731, #2016B Photon data
69  136.7611, #2016E JetHT reMINIAOD from 80X legacy
70  136.8311, #2017F JetHT reMINIAOD from 94X reprocessing
71  136.88811,#2018D JetHT reMINIAOD from UL processing
72  136.793, #2017C DoubleEG
73  136.874, #2018C EGamma
74  140.53, #2011 HI data
75  140.56, #2018 HI data
76  158.0, #2018 HI MC with pp-like reco
77  1306.0, #SingleMu Pt1 UP15
78  1325.7, #test NanoAOD from existing MINI
79  1330, #Run2 MC Zmm
80  135.4, #Run 2 Zee ttbar
81  10042.0, #2017 ZMM
82  10024.0, #2017 ttbar
83  10224.0, #2017 ttbar PU
84  10824.0, #2018 ttbar
85  11634.0, #2021 ttbar
86  12434.0, #2023 ttbar
87  20034.0, #2026D35 ttbar (MTD TDR baseline)
88  20434.0, #2026D41 ttbar (L1T TDR baseline)
89  21234.0, #2026D44 (exercise HF nose)
90  23234.0, #2026D49 ttbar (HLT TDR baseline w/ HGCal v11)
91  23234.1001, #as 23234.0 but reading 11_0_X digi inputs
92  25202.0, #2016 ttbar UP15 PU
93  250202.181, #2018 ttbar stage1 + stage2 premix
94  ],
95  'jetmc': [5.1, 13, 15, 25, 38, 39], #MC
96  'metmc' : [5.1, 15, 25, 37, 38, 39], #MC
97  'muonmc' : [5.1, 124.4, 124.5, 20, 21, 22, 23, 25, 30], #MC
98  }
99 
100 
101  import optparse
102  usage = 'usage: runTheMatrix.py --show -s '
103 
104  parser = optparse.OptionParser(usage)
105 
106  parser.add_option('-b','--batchName',
107  help='relval batch: suffix to be appended to Campaign name',
108  dest='batchName',
109  default=''
110  )
111 
112  parser.add_option('-m','--memoryOffset',
113  help='memory of the wf for single core',
114  dest='memoryOffset',
115  default=3000
116  )
117  parser.add_option('--addMemPerCore',
118  help='increase of memory per each n > 1 core: memory(n_core) = memoryOffset + (n_core-1) * memPerCore',
119  dest='memPerCore',
120  default=1500
121  )
122  parser.add_option('-j','--nproc',
123  help='number of processes. 0 Will use 4 processes, not execute anything but create the wfs',
124  dest='nProcs',
125  default=4
126  )
127  parser.add_option('-t','--nThreads',
128  help='number of threads per process to use in cmsRun.',
129  dest='nThreads',
130  default=1
131  )
132  parser.add_option('--numberEventsInLuminosityBlock',
133  help='number of events in a luminosity block',
134  dest='numberEventsInLuminosityBlock',
135  default=-1
136  )
137 
138  parser.add_option('-n','--showMatrix',
139  help='Only show the worflows. Use --ext to show more',
140  dest='show',
141  default=False,
142  action='store_true'
143  )
144  parser.add_option('-e','--extended',
145  help='Show details of workflows, used with --show',
146  dest='extended',
147  default=False,
148  action='store_true'
149  )
150  parser.add_option('-s','--selected',
151  help='Run a pre-defined selected matrix of wf. Deprecated, please use -l limited',
152  dest='restricted',
153  default=False,
154  action='store_true'
155  )
156  parser.add_option('-l','--list',
157  help='Coma separated list of workflow to be shown or ran. Possible keys are also '+str(predefinedSet.keys())+'. and wild card like muon, or mc',
158  dest='testList',
159  default=None
160  )
161  parser.add_option('-r','--raw',
162  help='Temporary dump the .txt needed for prodAgent interface. To be discontinued soon. Argument must be the name of the set (standard, pileup,...)',
163  dest='raw'
164  )
165  parser.add_option('-i','--useInput',
166  help='Use recyling where available. Either all, or a coma separated list of wf number.',
167  dest='useInput',
168  default=None
169  )
170  parser.add_option('-w','--what',
171  help='Specify the set to be used. Argument must be the name of the set (standard, pileup,...)',
172  dest='what',
173  default='all'
174  )
175  parser.add_option('--step1',
176  help='Used with --raw. Limit the production to step1',
177  dest='step1Only',
178  default=False
179  )
180  parser.add_option('--maxSteps',
181  help='Only run maximum on maxSteps. Used when we are only interested in first n steps.',
182  dest='maxSteps',
183  default=9999,
184  type="int"
185  )
186  parser.add_option('--fromScratch',
187  help='Coma separated list of wf to be run without recycling. all is not supported as default.',
188  dest='fromScratch',
189  default=None
190  )
191  parser.add_option('--refRelease',
192  help='Allow to modify the recycling dataset version',
193  dest='refRel',
194  default=None
195  )
196  parser.add_option('--wmcontrol',
197  help='Create the workflows for injection to WMAgent. In the WORKING. -wmcontrol init will create the the workflows, -wmcontrol test will dryRun a test, -wmcontrol submit will submit to wmagent',
198  choices=['init','test','submit','force'],
199  dest='wmcontrol',
200  default=None,
201  )
202  parser.add_option('--revertDqmio',
203  help='When submitting workflows to wmcontrol, force DQM outout to use pool and not DQMIO',
204  choices=['yes','no'],
205  dest='revertDqmio',
206  default='no',
207  )
208  parser.add_option('--optionswm',
209  help='Specify a few things for wm injection',
210  default='',
211  dest='wmoptions')
212  parser.add_option('--keep',
213  help='allow to specify for which coma separated steps the output is needed',
214  default=None)
215  parser.add_option('--label',
216  help='allow to give a special label to the output dataset name',
217  default='')
218  parser.add_option('--command',
219  help='provide a way to add additional command to all of the cmsDriver commands in the matrix',
220  dest='command',
221  default=None
222  )
223  parser.add_option('--apply',
224  help='allow to use the --command only for 1 coma separeated',
225  dest='apply',
226  default=None)
227  parser.add_option('--workflow',
228  help='define a workflow to be created or altered from the matrix',
229  action='append',
230  dest='workflow',
231  default=None
232  )
233  parser.add_option('--dryRun',
234  help='do not run the wf at all',
235  action='store_true',
236  dest='dryRun',
237  default=False
238  )
239  parser.add_option('--testbed',
240  help='workflow injection to cmswebtest (you need dedicated rqmgr account)',
241  dest='testbed',
242  default=False,
243  action='store_true'
244  )
245  parser.add_option('--noCafVeto',
246  help='Run from any source, ignoring the CAF label',
247  dest='cafVeto',
248  default=True,
249  action='store_false'
250  )
251  parser.add_option('--overWrite',
252  help='Change the content of a step for another. List of pairs.',
253  dest='overWrite',
254  default=None
255  )
256  parser.add_option('--noRun',
257  help='Remove all run list selection from wfs',
258  dest='noRun',
259  default=False,
260  action='store_true')
261 
262  parser.add_option('--das-options',
263  help='Options to be passed to dasgoclient.',
264  dest='dasOptions',
265  default="--limit 0",
266  action='store')
267 
268  parser.add_option('--job-reports',
269  help='Dump framework job reports',
270  dest='jobReports',
271  default=False,
272  action='store_true')
273 
274  parser.add_option('--ibeos',
275  help='Use IB EOS site configuration',
276  dest='IBEos',
277  default=False,
278  action='store_true')
279 
280  opt,args = parser.parse_args()
281  if opt.IBEos:
282  import os
283  try:from commands import getstatusoutput as run_cmd
284  except:from subprocess import getstatusoutput as run_cmd
285 
286  ibeos_cache = os.path.join(os.getenv("LOCALRT"), "ibeos_cache.txt")
287  if not os.path.exists(ibeos_cache):
288  err, out = run_cmd("curl -L -s -o %s https://raw.githubusercontent.com/cms-sw/cms-sw.github.io/master/das_queries/ibeos.txt" % ibeos_cache)
289  if err:
290  run_cmd("rm -f %s" % ibeos_cache)
291  print("Error: Unable to download ibeos cache information")
292  print(out)
293  sys.exit(err)
294 
295  for cmssw_env in [ "CMSSW_BASE", "CMSSW_RELEASE_BASE" ]:
296  cmssw_base = os.getenv(cmssw_env,None)
297  if not cmssw_base: continue
298  cmssw_base = os.path.join(cmssw_base,"src/Utilities/General/ibeos")
299  if os.path.exists(cmssw_base):
300  os.environ["PATH"]=cmssw_base+":"+os.getenv("PATH")
301  os.environ["CMS_PATH"]="/cvmfs/cms-ib.cern.ch"
302  os.environ["CMSSW_USE_IBEOS"]="true"
303  print(">> WARNING: You are using SITECONF from /cvmfs/cms-ib.cern.ch")
304  break
305  if opt.restricted:
306  print('Deprecated, please use -l limited')
307  if opt.testList: opt.testList+=',limited'
308  else: opt.testList='limited'
309 
310  def stepOrIndex(s):
311  if s.isdigit():
312  return int(s)
313  else:
314  return s
315  if opt.apply:
316  opt.apply=map(stepOrIndex,opt.apply.split(','))
317  if opt.keep:
318  opt.keep=map(stepOrIndex,opt.keep.split(','))
319 
320 
321 
322  if opt.testList:
323  testList=[]
324  for entry in opt.testList.split(','):
325  if not entry: continue
326  mapped=False
327  for k in predefinedSet:
328  if k.lower().startswith(entry.lower()) or k.lower().endswith(entry.lower()):
329  testList.extend(predefinedSet[k])
330  mapped=True
331  break
332  if not mapped:
333  try:
334  testList.append(float(entry))
335  except:
336  print(entry,'is not a possible selected entry')
337 
338  opt.testList = list(set(testList))
339 
340 
341  if opt.useInput: opt.useInput = opt.useInput.split(',')
342  if opt.fromScratch: opt.fromScratch = opt.fromScratch.split(',')
343  if opt.nProcs: opt.nProcs=int(opt.nProcs)
344  if opt.nThreads: opt.nThreads=int(opt.nThreads)
345  if (opt.numberEventsInLuminosityBlock): opt.numberEventsInLuminosityBlock=int(opt.numberEventsInLuminosityBlock)
346  if (opt.memoryOffset): opt.memoryOffset=int(opt.memoryOffset)
347  if (opt.memPerCore): opt.memPerCore=int(opt.memPerCore)
348 
349  if opt.wmcontrol:
351  if opt.overWrite:
352  opt.overWrite=eval(opt.overWrite)
353 
354  if opt.raw and opt.show:
355  ret = showRaw(opt)
356  else:
357  ret = runSelected(opt)
358 
359 
360  sys.exit(ret)
MatrixReader
Definition: MatrixReader.py:1
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
join
static std::string join(char **cmd)
Definition: RemoteFile.cc:17
MatrixRunner
Definition: MatrixRunner.py:1
runTheMatrix.showRaw
def showRaw(opt)
Definition: runTheMatrix.py:11
runTheMatrix.runSelected
def runSelected(opt)
Definition: runTheMatrix.py:20
str
#define str(s)
Definition: TestProcessor.cc:48
createfilelist.int
int
Definition: createfilelist.py:10
MatrixInjector.performInjectionOptionTest
def performInjectionOptionTest(opt)
Definition: MatrixInjector.py:12
MatrixInjector
Definition: MatrixInjector.py:1
edm::print
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
list
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*", "!HLTx*" if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL. It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of "!*" before the partial wildcard feature was incorporated). Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run
genParticles_cff.map
map
Definition: genParticles_cff.py:11
runTheMatrix.stepOrIndex
def stepOrIndex(s)
Definition: runTheMatrix.py:310