12 from datetime
import date
13 from optparse
import OptionParser
18 '''Batch manager specific to cmsRun processes.''' 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.",
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",
35 self.parser.add_option(
"--lst",
"--listfile",
"--lstfile", dest=
"lstfile", type=
"string",
36 help=
"lst file to read",
38 self.parser.add_option(
"--iovs",
"--iovfile", dest=
"iovfile", type=
"string",
39 help=
"IOV list to read",
41 self.parser.add_option(
"--trkselcfg",
"--trackselectionconfig", dest=
"trkselcfg", type=
"string",
42 help=
"Track selection config location",
44 self.parser.add_option(
"--notify",
"--sendto", dest=
"sendto", type=
"string",
45 help=
"Email addresses (comma-separated) to notify when job is complete.",
47 self.parser.add_option(
"--deform", action=
"store_true",
48 dest=
"useSD", default=
False,
49 help=
"Include surface deformations in alignment")
50 self.parser.add_option(
"-f",
"--force", action=
"store_true",
51 dest=
"force", default=
False,
52 help=
"Don't ask any questions, just over-write")
53 self.parser.add_option(
"--resubmit", action=
"store_true",
54 dest=
"resubmit", default=
False,
55 help=
"Resubmit a job from the last iteration")
56 self.parser.add_option(
"--dry", dest=
"dryRun", type=
"int",
58 help=
"Do not submit jobs, just set up the cfg files")
59 (self.opt,self.args) = self.parser.parse_args()
61 self.
mkdir(self.opt.outputdir)
63 if self.opt.lstfile
is None:
64 print "Unspecified lst file." 66 if self.opt.iovfile
is None:
67 print "Unspecified IOV list." 70 self.
jobname = self.opt.outputdir.split(
'/')[-1]
72 if self.opt.sendto
is not None:
73 self.opt.sendto.strip()
74 self.opt.sendto.replace(
",",
" ")
75 print "Job {} is configured to notify {}.".
format(self.
jobname, self.opt.sendto)
77 self.
SDflag = 1
if self.opt.useSD
else 0
81 mkdir =
'mkdir -p %s' % dirname
82 ret = os.system( mkdir )
84 print 'Please remove or rename directory: ', dirname
89 if self.opt.sendto
is not None:
90 strcmd =
"mail -s {1} {0} <<< \"{2}\"".
format(self.opt.sendto, self.
jobname, desc)
94 lastIter=self.opt.niter
95 doesExist=os.system(
"test -s {}/alignments_iter{}.db".
format(self.opt.outputdir, lastIter))
96 while (doesExist != 0):
100 doesExist=os.system(
"test -s {}/alignments_iter{}.db".
format(self.opt.outputdir, lastIter))
107 strresult =
"Jobs cannot be submitted for {}. Exiting...".
format(self.
jobname)
109 elif self.opt.dryRun > 0:
110 strresult =
"Dry run setup is complete for {}.".
format(self.
jobname)
113 if lastIter == self.opt.niter:
114 strresult =
"The final iteration {}/alignments_iter{}.db is recorded successfully.".
format(self.
jobname, lastIter)
116 strresult =
"The last successful iteration was {}/alignments_iter{}.db out of the {} requested iterations.".
format(self.
jobname, lastIter, self.opt.niter)
119 strresult =
"None of the {} iterations were successful in job {}.".
format(self.opt.niter, self.
jobname)
127 if self.opt.resubmit:
128 jobcmd =
'scripts/reiterator_py {} {} {} {} {} {}'.
format(
134 if self.opt.dryRun > 0:
135 print 'Dry run option is enabled. Will not submit jobs to the queue' 136 jobcmd =
'scripts/iterator_py {} {} {} {} {} {} {} {} {}'.
format(
147 ret = os.system( jobcmd )
155 if __name__ ==
'__main__':
157 batchManager.submitJobs()
def checkLastIteration(self)