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