CMS 3D CMS Logo

batchHippy.py
Go to the documentation of this file.
1 #!/bin/env python
2 
3 import sys
4 import imp
5 import copy
6 import os
7 import shutil
8 import pickle
9 import math
10 import pprint
11 import subprocess
12 from datetime import date
13 from optparse import OptionParser
14 
15 
16 
18  '''Batch manager specific to cmsRun processes.'''
19 
20  def __init__(self):
21  # define options and arguments ====================================
22  self.parser = OptionParser()
23  self.parser.add_option("-o", "--outdir", dest="outputdir", type="string",
24  help="Name of the local output directory for your jobs. This directory will be created automatically.",
25  default="./")
26  self.parser.add_option("--commoncfg", dest="commoncfg", type="string",
27  help="Name of the common config file.",
28  default="python/common_cff_py.txt")
29  self.parser.add_option("--aligncfg", dest="aligncfg", type="string",
30  help="Name of the align. config file.",
31  default="python/align_tpl_py.txt")
32  self.parser.add_option("--niter", dest="niter", type="int",
33  help="Number of iterations",
34  default="15")
35  self.parser.add_option("--lst", "--listfile", "--lstfile", dest="lstfile", type="string",
36  help="lst file to read",
37  default=None)
38  self.parser.add_option("--iovs", "--iovfile", dest="iovfile", type="string",
39  help="IOV list to read",
40  default=None)
41  self.parser.add_option("-f", "--force", action="store_true",
42  dest="force", default=False,
43  help="Don't ask any questions, just over-write")
44  self.parser.add_option("--resubmit", action="store_true",
45  dest="resubmit", default=False,
46  help="Resubmit a job from the last iteration")
47  (self.opt,self.args) = self.parser.parse_args()
48 
49  self.mkdir(self.opt.outputdir)
50 
51  if(self.opt.lstfile is None):
52  print "Unspecified lst file."
53  sys.exit(1)
54  if(self.opt.iovfile is None):
55  print "Unspecified IOV list."
56  sys.exit(1)
57 
58  def mkdir( self, dirname ):
59  mkdir = 'mkdir -p %s' % dirname
60  ret = os.system( mkdir )
61  if( ret != 0 ):
62  print 'Please remove or rename directory: ', dirname
63  sys.exit(4)
64 
65  def submitJobs(self):
66  jobcmd=""
67  if self.opt.resubmit:
68  jobcmd = 'scripts/reiterator_py {} {} {} {} {} {}'.format(
69  self.opt.niter,
70  self.opt.outputdir,
71  self.opt.iovfile
72  )
73  else:
74  jobcmd = 'scripts/iterator_py {} {} {} {} {} {}'.format(
75  self.opt.niter,
76  self.opt.outputdir,
77  self.opt.lstfile,
78  self.opt.iovfile,
79  self.opt.commoncfg,
80  self.opt.aligncfg
81  )
82  ret = os.system( jobcmd )
83  if( ret != 0 ):
84  sys.exit('Jobs cannot be submitted')
85 
86 
87 
88 
89 if __name__ == '__main__':
90  batchManager = MyBatchManager()
91  batchManager.submitJobs()
92 
if(dp >Float(M_PI)) dp-
def mkdir(self, dirname)
Definition: batchHippy.py:58