3 from __future__
import print_function
13 from datetime
import date
14 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(
"--redirectproxy", action=
"store_true",
57 dest=
"redirectproxy", default=
False,
58 help=
"Redirect the proxy to a path visible in batch")
59 self.
parser.add_option(
"--dry", dest=
"dryRun", type=
"int",
61 help=
"Do not submit jobs, just set up the cfg files")
66 self.
mkdir(self.opt.outputdir)
68 if self.opt.lstfile
is None:
69 print(
"Unspecified lst file.")
71 if self.opt.iovfile
is None:
72 print(
"Unspecified IOV list.")
75 self.
jobname = self.opt.outputdir.split(
'/')[-1]
77 if self.opt.redirectproxy:
81 if self.opt.sendto
is not None:
82 self.opt.sendto.strip()
83 self.opt.sendto.replace(
",",
" ")
87 self.
SDflag = 1
if self.opt.useSD
else 0
92 mkdir =
'mkdir -p %s' % dirname
93 ret = os.system( mkdir )
95 print(
'Please remove or rename directory: ', dirname)
100 if self.opt.sendto
is not None:
101 strcmd =
"mail -s {1} {0} <<< \"{2}\"".
format(self.opt.sendto, self.
jobname, desc)
105 lastIter=self.opt.niter
106 doesExist=os.system(
"test -s {}/alignments_iter{}.db".
format(self.opt.outputdir, lastIter))
107 while (doesExist != 0):
111 doesExist=os.system(
"test -s {}/alignments_iter{}.db".
format(self.opt.outputdir, lastIter))
118 strresult =
"Jobs cannot be submitted for {}. Exiting...".
format(self.
jobname)
120 elif self.opt.dryRun > 0:
121 strresult =
"Dry run setup is complete for {}.".
format(self.
jobname)
124 if lastIter == self.opt.niter:
125 strresult =
"The final iteration {}/alignments_iter{}.db is recorded successfully.".
format(self.
jobname, lastIter)
127 strresult =
"The last successful iteration was {}/alignments_iter{}.db out of the {} requested iterations.".
format(self.
jobname, lastIter, self.opt.niter)
130 strresult =
"None of the {} iterations were successful in job {}.".
format(self.opt.niter, self.
jobname)
138 if self.opt.resubmit:
139 jobcmd =
'scripts/reiterator_py {} {} {} {} {} {}'.
format(
145 if self.opt.dryRun > 0:
146 print(
'Dry run option is enabled. Will not submit jobs to the queue')
147 jobcmd =
'scripts/iterator_py {} {} {} {} {} {} {} {} {} {}'.
format(
159 ret = os.system( jobcmd )
164 subprocess.check_call([
"voms-proxy-info",
"--exists"])
165 except subprocess.CalledProcessError:
166 print(
"Please initialize your proxy before submitting.")
170 local_proxy = subprocess.check_output([
"voms-proxy-info",
"--path"]).
strip()
171 new_proxy_path = os.path.join(self.opt.outputdir,
".user_proxy")
172 print(
"Copying local proxy {} to the job directory as {}.".
format(local_proxy,new_proxy_path))
173 shutil.copyfile(local_proxy, new_proxy_path)
177 if __name__ ==
'__main__':
179 batchManager.submitJobs()
def checkLastIteration(self)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)