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