CMS 3D CMS Logo

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