CMS 3D CMS Logo

runTheMatrix.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 from __future__ import print_function
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  # test for wrong input workflows
26  if opt.testList:
27  definedSet = set([dwf.numId for dwf in mrd.workFlows])
28  testSet = set(opt.testList)
29  undefSet = testSet - definedSet
30  if len(undefSet)>0: raise ValueError('Undefined workflows: '+', '.join(map(str,list(undefSet))))
31 
32  ret = 0
33  if opt.show:
34  mrd.show(opt.testList, opt.extended, opt.cafVeto)
35  if opt.testList : print('testListected items:', opt.testList)
36  else:
37  mRunnerHi = MatrixRunner(mrd.workFlows, opt.nProcs, opt.nThreads)
38  ret = mRunnerHi.runTests(opt)
39 
40  if opt.wmcontrol:
41  if ret!=0:
42  print('Cannot go on with wmagent injection with failing workflows')
43  else:
44  wfInjector = MatrixInjector(opt,mode=opt.wmcontrol,options=opt.wmoptions)
45  ret= wfInjector.prepare(mrd,
46  mRunnerHi.runDirs)
47  if ret==0:
48  wfInjector.upload()
49  wfInjector.submit()
50  return ret
51 
52 # ================================================================================
53 
54 if __name__ == '__main__':
55 
56  #this can get out of here
57  predefinedSet={
58  'limited' : [5.1, #FastSim ttbar
59  7.3, #CosmicsSPLoose_UP17
60  8, #BH/Cosmic MC
61  25, #MC ttbar
62  4.22, #cosmic data
63  4.53, #run1 data + miniAOD
64  9.0, #Higgs200 charged taus
65  1000, #data+prompt
66  1001, #data+express
67  101.0, #SingleElectron120E120EHCAL
68  136.731, #2016B Photon data
69  136.7611, #2016E JetHT reMINIAOD from 80X legacy
70  136.8311, #2017F JetHT reMINIAOD from 94X reprocessing
71  136.788, #2017B Photon data
72  136.85, #2018A Egamma data
73  140.53, #2011 HI data
74  140.56, #2018 HI data
75  158.0, #2018 HI MC with pp-like reco
76  1306.0, #SingleMu Pt1 UP15
77  1325.7, #test NanoAOD from existing MINI
78  1330, #Run2 MC Zmm
79  135.4, #Run 2 Zee ttbar
80  10042.0, #2017 ZMM
81  10024.0, #2017 ttbar
82  10224.0, #2017 ttbar PU
83  10824.0, #2018 ttbar
84  11634.0, #2021 ttbar
85  12434.0, #2023 ttbar
86  20034.0, #2026D35 ttbar (MTD TDR baseline)
87  20434.0, #2026D41 ttbar (L1T TDR baseline)
88  21234.0, #2026D44 (exercise HF nose)
89  23234.0, #2026D49 ttbar (HLT TDR baseline w/ HGCal v11)
90  25202.0, #2016 ttbar UP15 PU
91  250202.181, #2018 ttbar stage1 + stage2 premix
92  ],
93  'jetmc': [5.1, 13, 15, 25, 38, 39], #MC
94  'metmc' : [5.1, 15, 25, 37, 38, 39], #MC
95  'muonmc' : [5.1, 124.4, 124.5, 20, 21, 22, 23, 25, 30], #MC
96  }
97 
98 
99  import optparse
100  usage = 'usage: runTheMatrix.py --show -s '
101 
102  parser = optparse.OptionParser(usage)
103 
104  parser.add_option('-b','--batchName',
105  help='relval batch: suffix to be appended to Campaign name',
106  dest='batchName',
107  default=''
108  )
109 
110  parser.add_option('-m','--memoryOffset',
111  help='memory of the wf for single core',
112  dest='memoryOffset',
113  default=3000
114  )
115  parser.add_option('--addMemPerCore',
116  help='increase of memory per each n > 1 core: memory(n_core) = memoryOffset + (n_core-1) * memPerCore',
117  dest='memPerCore',
118  default=1500
119  )
120  parser.add_option('-j','--nproc',
121  help='number of processes. 0 Will use 4 processes, not execute anything but create the wfs',
122  dest='nProcs',
123  default=4
124  )
125  parser.add_option('-t','--nThreads',
126  help='number of threads per process to use in cmsRun.',
127  dest='nThreads',
128  default=1
129  )
130 
131  parser.add_option('-n','--showMatrix',
132  help='Only show the worflows. Use --ext to show more',
133  dest='show',
134  default=False,
135  action='store_true'
136  )
137  parser.add_option('-e','--extended',
138  help='Show details of workflows, used with --show',
139  dest='extended',
140  default=False,
141  action='store_true'
142  )
143  parser.add_option('-s','--selected',
144  help='Run a pre-defined selected matrix of wf. Deprecated, please use -l limited',
145  dest='restricted',
146  default=False,
147  action='store_true'
148  )
149  parser.add_option('-l','--list',
150  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',
151  dest='testList',
152  default=None
153  )
154  parser.add_option('-r','--raw',
155  help='Temporary dump the .txt needed for prodAgent interface. To be discontinued soon. Argument must be the name of the set (standard, pileup,...)',
156  dest='raw'
157  )
158  parser.add_option('-i','--useInput',
159  help='Use recyling where available. Either all, or a coma separated list of wf number.',
160  dest='useInput',
161  default=None
162  )
163  parser.add_option('-w','--what',
164  help='Specify the set to be used. Argument must be the name of the set (standard, pileup,...)',
165  dest='what',
166  default='all'
167  )
168  parser.add_option('--step1',
169  help='Used with --raw. Limit the production to step1',
170  dest='step1Only',
171  default=False
172  )
173  parser.add_option('--maxSteps',
174  help='Only run maximum on maxSteps. Used when we are only interested in first n steps.',
175  dest='maxSteps',
176  default=9999,
177  type="int"
178  )
179  parser.add_option('--fromScratch',
180  help='Coma separated list of wf to be run without recycling. all is not supported as default.',
181  dest='fromScratch',
182  default=None
183  )
184  parser.add_option('--refRelease',
185  help='Allow to modify the recycling dataset version',
186  dest='refRel',
187  default=None
188  )
189  parser.add_option('--wmcontrol',
190  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',
191  choices=['init','test','submit','force'],
192  dest='wmcontrol',
193  default=None,
194  )
195  parser.add_option('--revertDqmio',
196  help='When submitting workflows to wmcontrol, force DQM outout to use pool and not DQMIO',
197  choices=['yes','no'],
198  dest='revertDqmio',
199  default='no',
200  )
201  parser.add_option('--optionswm',
202  help='Specify a few things for wm injection',
203  default='',
204  dest='wmoptions')
205  parser.add_option('--keep',
206  help='allow to specify for which coma separated steps the output is needed',
207  default=None)
208  parser.add_option('--label',
209  help='allow to give a special label to the output dataset name',
210  default='')
211  parser.add_option('--command',
212  help='provide a way to add additional command to all of the cmsDriver commands in the matrix',
213  dest='command',
214  default=None
215  )
216  parser.add_option('--apply',
217  help='allow to use the --command only for 1 coma separeated',
218  dest='apply',
219  default=None)
220  parser.add_option('--workflow',
221  help='define a workflow to be created or altered from the matrix',
222  action='append',
223  dest='workflow',
224  default=None
225  )
226  parser.add_option('--dryRun',
227  help='do not run the wf at all',
228  action='store_true',
229  dest='dryRun',
230  default=False
231  )
232  parser.add_option('--testbed',
233  help='workflow injection to cmswebtest (you need dedicated rqmgr account)',
234  dest='testbed',
235  default=False,
236  action='store_true'
237  )
238  parser.add_option('--noCafVeto',
239  help='Run from any source, ignoring the CAF label',
240  dest='cafVeto',
241  default=True,
242  action='store_false'
243  )
244  parser.add_option('--overWrite',
245  help='Change the content of a step for another. List of pairs.',
246  dest='overWrite',
247  default=None
248  )
249  parser.add_option('--noRun',
250  help='Remove all run list selection from wfs',
251  dest='noRun',
252  default=False,
253  action='store_true')
254 
255  parser.add_option('--das-options',
256  help='Options to be passed to dasgoclient.',
257  dest='dasOptions',
258  default="--limit 0",
259  action='store')
260 
261  parser.add_option('--job-reports',
262  help='Dump framework job reports',
263  dest='jobReports',
264  default=False,
265  action='store_true')
266 
267  parser.add_option('--ibeos',
268  help='Use IB EOS site configuration',
269  dest='IBEos',
270  default=False,
271  action='store_true')
272 
273  opt,args = parser.parse_args()
274  if opt.IBEos:
275  import os
276  try:from commands import getstatusoutput as run_cmd
277  except:from subprocess import getstatusoutput as run_cmd
278 
279  ibeos_cache = os.path.join(os.getenv("LOCALRT"), "ibeos_cache.txt")
280  if not os.path.exists(ibeos_cache):
281  err, out = run_cmd("curl -L -s -o %s https://raw.githubusercontent.com/cms-sw/cms-sw.github.io/master/das_queries/ibeos.txt" % ibeos_cache)
282  if err:
283  run_cmd("rm -f %s" % ibeos_cache)
284  print("Error: Unable to download ibeos cache information")
285  print(out)
286  sys.exit(err)
287 
288  for cmssw_env in [ "CMSSW_BASE", "CMSSW_RELEASE_BASE" ]:
289  cmssw_base = os.getenv(cmssw_env,None)
290  if not cmssw_base: continue
291  cmssw_base = os.path.join(cmssw_base,"src/Utilities/General/ibeos")
292  if os.path.exists(cmssw_base):
293  os.environ["PATH"]=cmssw_base+":"+os.getenv("PATH")
294  os.environ["CMS_PATH"]="/cvmfs/cms-ib.cern.ch"
295  os.environ["CMSSW_USE_IBEOS"]="true"
296  print(">> WARNING: You are using SITECONF from /cvmfs/cms-ib.cern.ch")
297  break
298  if opt.restricted:
299  print('Deprecated, please use -l limited')
300  if opt.testList: opt.testList+=',limited'
301  else: opt.testList='limited'
302 
303  def stepOrIndex(s):
304  if s.isdigit():
305  return int(s)
306  else:
307  return s
308  if opt.apply:
309  opt.apply=map(stepOrIndex,opt.apply.split(','))
310  if opt.keep:
311  opt.keep=map(stepOrIndex,opt.keep.split(','))
312 
313 
314 
315  if opt.testList:
316  testList=[]
317  for entry in opt.testList.split(','):
318  if not entry: continue
319  mapped=False
320  for k in predefinedSet:
321  if k.lower().startswith(entry.lower()) or k.lower().endswith(entry.lower()):
322  testList.extend(predefinedSet[k])
323  mapped=True
324  break
325  if not mapped:
326  try:
327  testList.append(float(entry))
328  except:
329  print(entry,'is not a possible selected entry')
330 
331  opt.testList = list(set(testList))
332 
333 
334  if opt.useInput: opt.useInput = opt.useInput.split(',')
335  if opt.fromScratch: opt.fromScratch = opt.fromScratch.split(',')
336  if opt.nProcs: opt.nProcs=int(opt.nProcs)
337  if opt.nThreads: opt.nThreads=int(opt.nThreads)
338  if (opt.memoryOffset): opt.memoryOffset=int(opt.memoryOffset)
339  if (opt.memPerCore): opt.memPerCore=int(opt.memPerCore)
340 
341  if opt.wmcontrol:
343  if opt.overWrite:
344  opt.overWrite=eval(opt.overWrite)
345 
346  if opt.raw and opt.show: ###prodAgent to be discontinued
347  ret = showRaw(opt)
348  else:
349  ret = runSelected(opt)
350 
351 
352  sys.exit(ret)
def performInjectionOptionTest(opt)
def runSelected(opt)
Definition: runTheMatrix.py:20
def showRaw(opt)
Definition: runTheMatrix.py:11
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
static std::string join(char **cmd)
Definition: RemoteFile.cc:17
def stepOrIndex(s)
#define str(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