CMS 3D CMS Logo

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