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