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  ret = 0
26  if opt.show:
27  mrd.show(opt.testList, opt.extended, opt.cafVeto)
28  if opt.testList : print('testListected items:', opt.testList)
29  else:
30  mRunnerHi = MatrixRunner(mrd.workFlows, opt.nProcs, opt.nThreads)
31  ret = mRunnerHi.runTests(opt)
32 
33  if opt.wmcontrol:
34  if ret!=0:
35  print('Cannot go on with wmagent injection with failing workflows')
36  else:
37  wfInjector = MatrixInjector(opt,mode=opt.wmcontrol,options=opt.wmoptions)
38  ret= wfInjector.prepare(mrd,
39  mRunnerHi.runDirs)
40  if ret==0:
41  wfInjector.upload()
42  wfInjector.submit()
43  return ret
44 
45 # ================================================================================
46 
47 if __name__ == '__main__':
48 
49  #this can get out of here
50  predefinedSet={
51  'limited' : [5.1, #FastSim ttbar
52  7.3, #CosmicsSPLoose_UP17
53  8, #BH/Cosmic MC
54  25, #MC ttbar
55  4.22, #cosmic data
56  4.53, #run1 data + miniAOD
57  9.0, #Higgs200 charged taus
58  1000, #data+prompt
59  1001, #data+express
60  101.0, #SingleElectron120E120EHCAL
61  136.731, #2016B Photon data
62  136.7611, #2016E JetHT reMINIAOD from 80X legacy
63  136.8311, #2017F JetHT reMINIAOD from 94X reprocessing
64  136.88811,#2018D JetHT reMINIAOD from UL processing
65  136.788, #2017B Photon data
66  136.85, #2018A Egamma data
67  140.53, #2011 HI data
68  140.56, #2018 HI data
69  158.0, #2018 HI MC with pp-like reco
70  1306.0, #SingleMu Pt1 UP15
71  1325.81, #test NanoAOD from existing MINI UL 106Xv1
72  136.8523, #test NanoAOD from existing reMINI UL 106Xv2
73  1330, #Run2 MC Zmm
74  135.4, #Run 2 Zee ttbar
75  10042.0, #2017 ZMM
76  10024.0, #2017 ttbar
77  10224.0, #2017 ttbar PU
78  10824.0, #2018 ttbar
79  11624.0, #2021 ttbar
80  20034.0, #2023D17 ttbar (TDR baseline Muon/Barrel)
81  21234.0, #2023D21 ttbar (Inner Tracker with lower radii than in TDR)
82  27434.0, #2023D35 to exercise new HGCal + new MTD
83  29034.0, #2023D41 (baseline for L1T TDR)
84  25202.0, #2016 ttbar UP15 PU
85  250202.181, #2018 ttbar stage1 + stage2 premix
86  ],
87  'jetmc': [5.1, 13, 15, 25, 38, 39], #MC
88  'metmc' : [5.1, 15, 25, 37, 38, 39], #MC
89  'muonmc' : [5.1, 124.4, 124.5, 20, 21, 22, 23, 25, 30], #MC
90  }
91 
92 
93  import optparse
94  usage = 'usage: runTheMatrix.py --show -s '
95 
96  parser = optparse.OptionParser(usage)
97 
98  parser.add_option('-b','--batchName',
99  help='relval batch: suffix to be appended to Campaign name',
100  dest='batchName',
101  default=''
102  )
103 
104  parser.add_option('-m','--memoryOffset',
105  help='memory of the wf for single core',
106  dest='memoryOffset',
107  default=3000
108  )
109  parser.add_option('--addMemPerCore',
110  help='increase of memory per each n > 1 core: memory(n_core) = memoryOffset + (n_core-1) * memPerCore',
111  dest='memPerCore',
112  default=1500
113  )
114  parser.add_option('-j','--nproc',
115  help='number of processes. 0 Will use 4 processes, not execute anything but create the wfs',
116  dest='nProcs',
117  default=4
118  )
119  parser.add_option('-t','--nThreads',
120  help='number of threads per process to use in cmsRun.',
121  dest='nThreads',
122  default=1
123  )
124 
125  parser.add_option('-n','--showMatrix',
126  help='Only show the worflows. Use --ext to show more',
127  dest='show',
128  default=False,
129  action='store_true'
130  )
131  parser.add_option('-e','--extended',
132  help='Show details of workflows, used with --show',
133  dest='extended',
134  default=False,
135  action='store_true'
136  )
137  parser.add_option('-s','--selected',
138  help='Run a pre-defined selected matrix of wf. Deprecated, please use -l limited',
139  dest='restricted',
140  default=False,
141  action='store_true'
142  )
143  parser.add_option('-l','--list',
144  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',
145  dest='testList',
146  default=None
147  )
148  parser.add_option('-r','--raw',
149  help='Temporary dump the .txt needed for prodAgent interface. To be discontinued soon. Argument must be the name of the set (standard, pileup,...)',
150  dest='raw'
151  )
152  parser.add_option('-i','--useInput',
153  help='Use recyling where available. Either all, or a coma separated list of wf number.',
154  dest='useInput',
155  default=None
156  )
157  parser.add_option('-w','--what',
158  help='Specify the set to be used. Argument must be the name of the set (standard, pileup,...)',
159  dest='what',
160  default='all'
161  )
162  parser.add_option('--step1',
163  help='Used with --raw. Limit the production to step1',
164  dest='step1Only',
165  default=False
166  )
167  parser.add_option('--maxSteps',
168  help='Only run maximum on maxSteps. Used when we are only interested in first n steps.',
169  dest='maxSteps',
170  default=9999,
171  type="int"
172  )
173  parser.add_option('--fromScratch',
174  help='Coma separated list of wf to be run without recycling. all is not supported as default.',
175  dest='fromScratch',
176  default=None
177  )
178  parser.add_option('--refRelease',
179  help='Allow to modify the recycling dataset version',
180  dest='refRel',
181  default=None
182  )
183  parser.add_option('--wmcontrol',
184  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',
185  choices=['init','test','submit','force'],
186  dest='wmcontrol',
187  default=None,
188  )
189  parser.add_option('--revertDqmio',
190  help='When submitting workflows to wmcontrol, force DQM outout to use pool and not DQMIO',
191  choices=['yes','no'],
192  dest='revertDqmio',
193  default='no',
194  )
195  parser.add_option('--optionswm',
196  help='Specify a few things for wm injection',
197  default='',
198  dest='wmoptions')
199  parser.add_option('--keep',
200  help='allow to specify for which coma separated steps the output is needed',
201  default=None)
202  parser.add_option('--label',
203  help='allow to give a special label to the output dataset name',
204  default='')
205  parser.add_option('--command',
206  help='provide a way to add additional command to all of the cmsDriver commands in the matrix',
207  dest='command',
208  default=None
209  )
210  parser.add_option('--apply',
211  help='allow to use the --command only for 1 coma separeated',
212  dest='apply',
213  default=None)
214  parser.add_option('--workflow',
215  help='define a workflow to be created or altered from the matrix',
216  action='append',
217  dest='workflow',
218  default=None
219  )
220  parser.add_option('--dryRun',
221  help='do not run the wf at all',
222  action='store_true',
223  dest='dryRun',
224  default=False
225  )
226  parser.add_option('--testbed',
227  help='workflow injection to cmswebtest (you need dedicated rqmgr account)',
228  dest='testbed',
229  default=False,
230  action='store_true'
231  )
232  parser.add_option('--noCafVeto',
233  help='Run from any source, ignoring the CAF label',
234  dest='cafVeto',
235  default=True,
236  action='store_false'
237  )
238  parser.add_option('--overWrite',
239  help='Change the content of a step for another. List of pairs.',
240  dest='overWrite',
241  default=None
242  )
243  parser.add_option('--noRun',
244  help='Remove all run list selection from wfs',
245  dest='noRun',
246  default=False,
247  action='store_true')
248 
249  parser.add_option('--das-options',
250  help='Options to be passed to dasgoclient.',
251  dest='dasOptions',
252  default="--limit 0",
253  action='store')
254 
255  parser.add_option('--job-reports',
256  help='Dump framework job reports',
257  dest='jobReports',
258  default=False,
259  action='store_true')
260 
261  parser.add_option('--ibeos',
262  help='Use IB EOS site configuration',
263  dest='IBEos',
264  default=False,
265  action='store_true')
266 
267  parser.add_option('--dbs-url',
268  help='Overwrite DbsUrl value in JSON submitted to ReqMgr2',
269  dest='dbsUrl',
270  default=None,
271  action='store')
272 
273  opt,args = parser.parse_args()
274  if opt.IBEos:
275  import os
276  from commands import getstatusoutput as run_cmd
277  ibeos_cache = os.path.join(os.getenv("LOCALRT"), "ibeos_cache.txt")
278  if not os.path.exists(ibeos_cache):
279  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)
280  if err:
281  run_cmd("rm -f %s" % ibeos_cache)
282  print("Error: Unable to download ibeos cache information")
283  print(out)
284  sys.exit(err)
285 
286  for cmssw_env in [ "CMSSW_BASE", "CMSSW_RELEASE_BASE" ]:
287  cmssw_base = os.getenv(cmssw_env,None)
288  if not cmssw_base: continue
289  cmssw_base = os.path.join(cmssw_base,"src/Utilities/General/ibeos")
290  if os.path.exists(cmssw_base):
291  os.environ["PATH"]=cmssw_base+":"+os.getenv("PATH")
292  os.environ["CMS_PATH"]="/cvmfs/cms-ib.cern.ch"
293  os.environ["CMSSW_USE_IBEOS"]="true"
294  print(">> WARNING: You are using SITECONF from /cvmfs/cms-ib.cern.ch")
295  break
296  if opt.restricted:
297  print('Deprecated, please use -l limited')
298  if opt.testList: opt.testList+=',limited'
299  else: opt.testList='limited'
300 
301  def stepOrIndex(s):
302  if s.isdigit():
303  return int(s)
304  else:
305  return s
306  if opt.apply:
307  opt.apply=map(stepOrIndex,opt.apply.split(','))
308  if opt.keep:
309  opt.keep=map(stepOrIndex,opt.keep.split(','))
310 
311 
312 
313  if opt.testList:
314  testList=[]
315  for entry in opt.testList.split(','):
316  if not entry: continue
317  mapped=False
318  for k in predefinedSet:
319  if k.lower().startswith(entry.lower()) or k.lower().endswith(entry.lower()):
320  testList.extend(predefinedSet[k])
321  mapped=True
322  break
323  if not mapped:
324  try:
325  testList.append(float(entry))
326  except:
327  print(entry,'is not a possible selected entry')
328 
329  opt.testList = list(set(testList))
330 
331 
332  if opt.useInput: opt.useInput = opt.useInput.split(',')
333  if opt.fromScratch: opt.fromScratch = opt.fromScratch.split(',')
334  if opt.nProcs: opt.nProcs=int(opt.nProcs)
335  if opt.nThreads: opt.nThreads=int(opt.nThreads)
336  if (opt.memoryOffset): opt.memoryOffset=int(opt.memoryOffset)
337  if (opt.memPerCore): opt.memPerCore=int(opt.memPerCore)
338 
339  if opt.wmcontrol:
341  if opt.overWrite:
342  opt.overWrite=eval(opt.overWrite)
343 
344  if opt.raw and opt.show: ###prodAgent to be discontinued
345  ret = showRaw(opt)
346  else:
347  ret = runSelected(opt)
348 
349 
350  sys.exit(ret)
def performInjectionOptionTest(opt)
def runSelected(opt)
Definition: runTheMatrix.py:20
def showRaw(opt)
Definition: runTheMatrix.py:11
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
def stepOrIndex(s)
#define str(s)
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