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