19 parser = argparse.ArgumentParser()
20 parser.add_argument(
"foldername", help=
"folder name for the campaign. Example: CRUZET20xy")
21 parser.add_argument(
"--cmssw", default=os.environ[
"CMSSW_VERSION"])
22 parser.add_argument(
"--scram-arch", default=os.environ[
"SCRAM_ARCH"])
23 parser.add_argument(
"--subfolder", default=
"", help=
"subfolder within "+basedir+
" to make 'foldername' in.")
24 parser.add_argument(
"--merge-topic", action=
"append", help=
"things to cms-merge-topic within the CMSSW release created", default=[])
25 parser.add_argument(
"--print-sys-path", action=
"store_true", help=argparse.SUPPRESS)
26 args = parser.parse_args()
28 if args.print_sys_path:
32 folder = os.path.join(basedir, args.subfolder, args.foldername)
37 if not os.path.exists(args.cmssw):
38 os.environ[
"SCRAM_ARCH"] = args.scram_arch
39 subprocess.check_call([
"scram",
"p",
"CMSSW", args.cmssw])
42 for _
in args.merge_topic:
43 subprocess.check_call([
"git",
"cms-merge-topic", _])
44 os.system(
"eval $(scram ru -sh) && scram b -j 10")
46 if os.path.exists(
"src/Alignment/HIPAlignmentAlgorithm"):
47 HIPAlignmentAlgorithm = os.path.abspath(
"src/Alignment/HIPAlignmentAlgorithm")
49 with cd(os.environ[
"CMSSW_RELEASE_BASE"]):
50 HIPAlignmentAlgorithm = os.path.abspath(
"src/Alignment/HIPAlignmentAlgorithm")
52 assert os.path.exists(HIPAlignmentAlgorithm), HIPAlignmentAlgorithm
58 subprocess.check_call([
"git",
"init"])
61 with cd(
"Configurations"):
62 if not os.path.exists(
"align_tpl_py.txt"):
63 shutil.copy(os.path.join(HIPAlignmentAlgorithm,
"python",
"align_tpl_py.txt"),
".")
64 subprocess.check_call([
"git",
"add",
"align_tpl_py.txt"])
65 if not os.path.exists(
"common_cff_py_TEMPLATE.txt"):
66 shutil.copy(os.path.join(HIPAlignmentAlgorithm,
"python",
"common_cff_py.txt"),
"common_cff_py_TEMPLATE.txt")
67 subprocess.check_call([
"git",
"add",
"common_cff_py_TEMPLATE.txt"])
69 with cd(
"TrackSelection"):
70 for _
in glob.iglob(os.path.join(HIPAlignmentAlgorithm,
"python",
"*TrackSelection_cff_py.txt")):
71 if not os.path.exists(os.path.basename(_)):
73 subprocess.check_call([
"git",
"add", os.path.basename(_)])
77 if not os.path.exists(
"data_example.lst"):
78 with open(
"data_example.lst",
"w")
as f:
79 f.write(os.path.join(os.getcwd(),
"minbias.txt") +
",,MBVertex,Datatype:0\n")
80 f.write(os.path.join(os.getcwd(),
"cosmics.txt") +
",,COSMICS,Datatype:1 APVMode:deco Bfield:3.8T\n")
81 f.write(os.path.join(os.getcwd(),
"CDCs.txt") +
",,CDCS,Datatype:1 APVMode:deco Bfield:3.8T\n")
82 subprocess.check_call([
"git",
"add",
"data_example.lst"])
83 if not os.path.exists(
"baddatafiles.txt"):
84 with open(
"baddatafiles.txt",
"w")
as f:
85 f.write(
"If any data files are bad (e.g. not at CERN), put them here,\n")
86 f.write(
"separated by newlines or spaces or nothing or whatever you like.\n")
87 f.write(
"Anything else in this file, like these lines, will be ignored.\n")
88 f.write(
"You can also run hippyaddtobaddatafiles.py .../align_cfg.py to automatically\n")
89 f.write(
"find bad data files.\n")
90 f.write(
"Running jobs will automatically pick up changes here next time they resubmit.")
94 if not os.path.exists(
"RunXXXXXX"):
95 with open(
"RunXXXXXX",
"w")
as f:
97 subprocess.check_call([
"git",
"add",
"RunXXXXXX"])
99 if not os.path.exists(
"submit_template.sh"):
100 shutil.copy(os.path.join(HIPAlignmentAlgorithm,
"test",
"hippysubmittertemplate.sh"),
"submit_template.sh")
101 os.chmod(
"submit_template.sh", os.stat(
"submit_template.sh").st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
102 subprocess.check_call([
"git",
"add",
"submit_template.sh"])
105 subprocess.check_output([
"git",
"diff",
"--staged",
"--quiet"])
106 except subprocess.CalledProcessError:
107 subprocess.check_call([
"git",
"commit",
"-m",
"commit templates"])