CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_1/src/Configuration/PyReleaseValidation/scripts/runTheMatrix.py

Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 import sys
00004 
00005 from Configuration.PyReleaseValidation.MatrixReader import MatrixReader
00006 from Configuration.PyReleaseValidation.MatrixRunner import MatrixRunner
00007 from Configuration.PyReleaseValidation.MatrixInjector import MatrixInjector,performInjectionOptionTest
00008         
00009 # ================================================================================
00010 
00011 def showRaw(opt):
00012 
00013     mrd = MatrixReader(opt)
00014     mrd.showRaw(opt.useInput, opt.refRel, opt.fromScratch, opt.raw, opt.step1Only, selected=opt.testList)
00015 
00016     return 0
00017         
00018 # ================================================================================
00019 
00020 def runSelected(opt):
00021 
00022     mrd = MatrixReader(opt)
00023     mrd.prepare(opt.useInput, opt.refRel, opt.fromScratch)
00024 
00025     ret = 0
00026     if opt.show:
00027         mrd.show(opt.testList,opt.extended)
00028         if opt.testList : print 'testListected items:', opt.testList
00029     else:
00030         mRunnerHi = MatrixRunner(mrd.workFlows, opt.nThreads)
00031         ret = mRunnerHi.runTests(opt)
00032 
00033     if opt.wmcontrol:
00034         if ret!=0:
00035             print 'Cannot go on with wmagent injection with failing workflows'
00036         else:
00037             wfInjector = MatrixInjector(mode=opt.wmcontrol)
00038             ret= wfInjector.prepare(mrd,
00039                                     mRunnerHi.runDirs)
00040             if ret==0:
00041                 wfInjector.upload()
00042                 wfInjector.submit()
00043     return ret
00044 
00045 # ================================================================================
00046 
00047 if __name__ == '__main__':
00048 
00049     #this can get out of here
00050     predefinedSet={
00051         'limited' : [5.1, #FastSim ttbar
00052                      8, #BH/Cosmic MC
00053                      25, #MC ttbar
00054                      4.22, #cosmic data
00055                      4.291, #hlt data
00056                      1000, #data+prompt
00057                      1001, #data+express
00058                      4.53, #HI data
00059                      40, #HI MC
00060                      ],
00061         'jetmc': [5.1, 13, 15, 25, 38, 39], #MC
00062         'metmc' : [5.1, 15, 25, 37, 38, 39], #MC
00063         'muonmc' : [5.1, 124.4, 124.5, 20, 21, 22, 23, 25, 30], #MC
00064         }
00065         
00066 
00067     import optparse
00068     usage = 'usage: runTheMatrix.py --show -s '
00069 
00070     parser = optparse.OptionParser(usage)
00071 
00072     parser.add_option('-j','--nproc',
00073                       help='number of threads. 0 Will use 4 threads, not execute anything but create the wfs',
00074                       dest='nThreads',
00075                       default=4
00076                      )
00077     parser.add_option('-n','--showMatrix',
00078                       help='Only show the worflows. Use --ext to show more',
00079                       dest='show',
00080                       default=False,
00081                       action='store_true'
00082                       )
00083     parser.add_option('-e','--extended',
00084                       help='Show details of workflows, used with --show',
00085                       dest='extended',
00086                       default=False,
00087                       action='store_true'
00088                       )
00089     parser.add_option('-s','--selected',
00090                       help='Run a pre-defined selected matrix of wf. Deprecated, please use -l limited',
00091                       dest='restricted',
00092                       default=False,
00093                       action='store_true'
00094                       )
00095     parser.add_option('-l','--list',
00096                      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',
00097                      dest='testList',
00098                      default=None
00099                      )
00100     parser.add_option('-r','--raw',
00101                       help='Temporary dump the .txt needed for prodAgent interface. To be discontinued soon. Argument must be the name of the set (standard, pileup,...)',
00102                       dest='raw'
00103                       )
00104     parser.add_option('-i','--useInput',
00105                       help='Use recyling where available',
00106                       dest='useInput',
00107                       default=None
00108                       )
00109     parser.add_option('-w','--what',
00110                       help='Specify the set to be used. Argument must be the name of the set (standard, pileup,...)',
00111                       dest='what',
00112                       default='all'
00113                       )
00114     parser.add_option('--step1',
00115                       help='Used with --raw. Limit the production to step1',
00116                       dest='step1Only',
00117                       default=False
00118                       )
00119     parser.add_option('--fromScratch',
00120                       help='Coma separated list of wf to be run without recycling. all is not supported as default.',
00121                       dest='fromScratch',
00122                       default=None
00123                        )
00124     parser.add_option('--refRelease',
00125                       help='Allow to modify the recycling dataset version',
00126                       dest='refRel',
00127                       default=None
00128                       )
00129     parser.add_option('--wmcontrol',
00130                       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',
00131                       choices=['init','test','submit','force'],
00132                       dest='wmcontrol',
00133                       default=None,
00134                       )
00135     parser.add_option('--command',
00136                       help='provide a way to add additional command to all of the cmsDriver commands in the matrix',
00137                       dest='command',
00138                       default=None
00139                       )
00140     parser.add_option('--workflow',
00141                       help='define a workflow to be created or altered from the matrix',
00142                       action='append',
00143                       dest='workflow',
00144                       default=None
00145                       )
00146     parser.add_option('--dryRun',
00147                       help='do not run the wf at all',
00148                       action='store_true',
00149                       dest='dryRun',
00150                       default=False
00151                       )
00152     parser.add_option('--noCafVeto',
00153                       help='Run from any source, ignoring the CAF label',
00154                       dest='cafVeto',
00155                       default=True,
00156                       action='store_false'
00157                       )
00158     parser.add_option('--overWrite',
00159                       help='Change the content of a step for another. List of pairs.',
00160                       dest='overWrite',
00161                       default=None
00162                       )
00163     
00164     opt,args = parser.parse_args()
00165     if opt.restricted:
00166         print 'Deprecated, please use -l limited'
00167         if opt.testList:            opt.testList+=',limited'
00168         else:            opt.testList='limited'
00169         
00170     if opt.testList:
00171         testList=[]
00172         for entry in opt.testList.split(','):
00173             if not entry: continue
00174             mapped=False
00175             for k in predefinedSet:
00176                 if k.lower().startswith(entry.lower()) or k.lower().endswith(entry.lower()):
00177                     testList.extend(predefinedSet[k])
00178                     mapped=True
00179                     break
00180             if not mapped:
00181                 try:
00182                     testList.append(float(entry))
00183                 except:
00184                     print entry,'is not a possible selected entry'
00185             
00186         opt.testList = list(set(testList))
00187 
00188 
00189     if opt.useInput: opt.useInput = opt.useInput.split(',')
00190     if opt.fromScratch: opt.fromScratch = opt.fromScratch.split(',')
00191     if opt.nThreads: opt.nThreads=int(opt.nThreads)
00192 
00193     if opt.wmcontrol:
00194         performInjectionOptionTest(opt)
00195     if opt.overWrite:
00196         opt.overWrite=eval(opt.overWrite)
00197 
00198     if opt.raw and opt.show: ###prodAgent to be discontinued
00199         ret = showRaw(opt)
00200     else:
00201         ret = runSelected(opt)
00202 
00203 
00204     sys.exit(ret)