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 
3 import sys
4 
5 from Configuration.PyReleaseValidation.MatrixReader import MatrixReader
6 from Configuration.PyReleaseValidation.MatrixRunner import MatrixRunner
7 from Configuration.PyReleaseValidation.MatrixInjector import MatrixInjector,performInjectionOptionTest
8 
9 # ================================================================================
10 
11 def showRaw(opt):
12 
13  mrd = MatrixReader(opt)
14  mrd.showRaw(opt.useInput, opt.refRel, opt.fromScratch, opt.raw, opt.step1Only, selected=opt.testList)
15 
16  return 0
17 
18 # ================================================================================
19 
20 def runSelected(opt):
21 
22  mrd = MatrixReader(opt)
23  mrd.prepare(opt.useInput, opt.refRel, opt.fromScratch)
24 
25  ret = 0
26  if opt.show:
27  mrd.show(opt.testList,opt.extended)
28  if opt.testList : print 'testListected items:', opt.testList
29  else:
30  mRunnerHi = MatrixRunner(mrd.workFlows, opt.nThreads)
31  ret = mRunnerHi.runTests(opt)
32 
33  if opt.wmcontrol:
34  if ret!=0:
35  print 'Cannot go on with wmagent injection with failing workflows'
36  else:
37  wfInjector = MatrixInjector(opt,mode=opt.wmcontrol)
38  ret= wfInjector.prepare(mrd,
39  mRunnerHi.runDirs)
40  if ret==0:
41  wfInjector.upload()
42  wfInjector.submit()
43  return ret
44 
45 # ================================================================================
46 
47 if __name__ == '__main__':
48 
49  #this can get out of here
50  predefinedSet={
51  'limited' : [5.1, #FastSim ttbar
52  8, #BH/Cosmic MC
53  25, #MC ttbar
54  4.22, #cosmic data
55  4.291, #hlt data
56  1000, #data+prompt
57  1001, #data+express
58  4.53, #HI data
59  40, #HI MC
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 threads. 0 Will use 4 threads, not execute anything but create the wfs',
74  dest='nThreads',
75  default=4
76  )
77  parser.add_option('-n','--showMatrix',
78  help='Only show the worflows. Use --ext to show more',
79  dest='show',
80  default=False,
81  action='store_true'
82  )
83  parser.add_option('-e','--extended',
84  help='Show details of workflows, used with --show',
85  dest='extended',
86  default=False,
87  action='store_true'
88  )
89  parser.add_option('-s','--selected',
90  help='Run a pre-defined selected matrix of wf. Deprecated, please use -l limited',
91  dest='restricted',
92  default=False,
93  action='store_true'
94  )
95  parser.add_option('-l','--list',
96  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',
97  dest='testList',
98  default=None
99  )
100  parser.add_option('-r','--raw',
101  help='Temporary dump the .txt needed for prodAgent interface. To be discontinued soon. Argument must be the name of the set (standard, pileup,...)',
102  dest='raw'
103  )
104  parser.add_option('-i','--useInput',
105  help='Use recyling where available. Either all, or a coma separated list of wf number.',
106  dest='useInput',
107  default=None
108  )
109  parser.add_option('-w','--what',
110  help='Specify the set to be used. Argument must be the name of the set (standard, pileup,...)',
111  dest='what',
112  default='all'
113  )
114  parser.add_option('--step1',
115  help='Used with --raw. Limit the production to step1',
116  dest='step1Only',
117  default=False
118  )
119  parser.add_option('--fromScratch',
120  help='Coma separated list of wf to be run without recycling. all is not supported as default.',
121  dest='fromScratch',
122  default=None
123  )
124  parser.add_option('--refRelease',
125  help='Allow to modify the recycling dataset version',
126  dest='refRel',
127  default=None
128  )
129  parser.add_option('--wmcontrol',
130  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',
131  choices=['init','test','submit','force'],
132  dest='wmcontrol',
133  default=None,
134  )
135  parser.add_option('--keep',
136  help='allow to specify for which coma separated steps the output is needed',
137  default=None)
138  parser.add_option('--label',
139  help='allow to give a special label to the output dataset name',
140  default='')
141  parser.add_option('--command',
142  help='provide a way to add additional command to all of the cmsDriver commands in the matrix',
143  dest='command',
144  default=None
145  )
146  parser.add_option('--apply',
147  help='allow to use the --command only for 1 coma separeated',
148  dest='apply',
149  default=None)
150  parser.add_option('--workflow',
151  help='define a workflow to be created or altered from the matrix',
152  action='append',
153  dest='workflow',
154  default=None
155  )
156  parser.add_option('--dryRun',
157  help='do not run the wf at all',
158  action='store_true',
159  dest='dryRun',
160  default=False
161  )
162  parser.add_option('--noCafVeto',
163  help='Run from any source, ignoring the CAF label',
164  dest='cafVeto',
165  default=True,
166  action='store_false'
167  )
168  parser.add_option('--overWrite',
169  help='Change the content of a step for another. List of pairs.',
170  dest='overWrite',
171  default=None
172  )
173  parser.add_option('--noRun',
174  help='Remove all run list selection from wfs',
175  dest='noRun',
176  default=False,
177  action='store_true')
178 
179 
180 
181  opt,args = parser.parse_args()
182  if opt.restricted:
183  print 'Deprecated, please use -l limited'
184  if opt.testList: opt.testList+=',limited'
185  else: opt.testList='limited'
186 
187  def stepOrIndex(s):
188  if s.isdigit():
189  return int(s)
190  else:
191  return s
192  if opt.apply:
193  opt.apply=map(stepOrIndex,opt.apply.split(','))
194  if opt.keep:
195  opt.keep=map(stepOrIndex,opt.keep.split(','))
196 
197 
198 
199  if opt.testList:
200  testList=[]
201  for entry in opt.testList.split(','):
202  if not entry: continue
203  mapped=False
204  for k in predefinedSet:
205  if k.lower().startswith(entry.lower()) or k.lower().endswith(entry.lower()):
206  testList.extend(predefinedSet[k])
207  mapped=True
208  break
209  if not mapped:
210  try:
211  testList.append(float(entry))
212  except:
213  print entry,'is not a possible selected entry'
214 
215  opt.testList = list(set(testList))
216 
217 
218  if opt.useInput: opt.useInput = opt.useInput.split(',')
219  if opt.fromScratch: opt.fromScratch = opt.fromScratch.split(',')
220  if opt.nThreads: opt.nThreads=int(opt.nThreads)
221 
222  if opt.wmcontrol:
224  if opt.overWrite:
225  opt.overWrite=eval(opt.overWrite)
226 
227  if opt.raw and opt.show: ###prodAgent to be discontinued
228  ret = showRaw(opt)
229  else:
230  ret = runSelected(opt)
231 
232 
233  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
void set(const std::string &name, int value)
set the flag, with a run-time name