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