forked from cms-PdmV/wmcontrol
-
Notifications
You must be signed in to change notification settings - Fork 1
/
launch_full_rereco.py
executable file
·124 lines (92 loc) · 3.85 KB
/
launch_full_rereco.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#! /usr/bin/env python
import sys
from ConfigParser import SafeConfigParser
import os
sys.path.append(os.path.join(sys.path[0], 'modules'))
from full_rereco import *
import optparse
#-------------------------------------------------------------------------------
def build_parser():
#global request_upload
usage= "Run with\n"
usage+="%prog --reprocfg myinicfg.ini --prepare_configs\n"
usage+="%prog --reprocfg myinicfg.ini --upload\n"
usage+="%prog --reprocfg myinicfg.ini --request\n"
parser = optparse.OptionParser(usage)
parser.add_option("--upload",default=False,action='store_true',
help="use this option to upload the configurations to couchDB")
parser.add_option("--request",default=False,action='store_true',
help="use this option to actually send the request to the request-manager web interface")
parser.add_option("--lastRun",default=-1)
parser.add_option("--firstRun",default=-1)
# new options
parser.add_option("--reprocfg",default=None,
help="Specify the reprocessing configfile")
parser.add_option("--prepare_configs",default=False,action='store_true',
help="Prepare all the configurations")
parser.add_option("--test",default=False,action='store_true',
help="Do a dry run")
options,args=parser.parse_args()
return options,args
#-------------------------------------------------------------------------------
def commasep2list(string):
list_str=string.replace("\n"," ")
list_str=list_str.replace(" ","")
#print list_str
the_list=list_str.split(",")
return the_list
#-------------------------------------------------------------------------------
def get_params(cfgfilename):
if cfgfilename==None:
print "No configfile selected!"
sys.exit(1)
if not os.path.exists(cfgfilename):
print "Configfile %s does not exist: please select an existing one!" %cfgfilename
sys.exit(1)
parser = SafeConfigParser()
parser.read(cfgfilename)
section = "reprocessing"
try:
globaltag=requestDefault["GlobalTag"] = parser.get(section, 'globaltag')
except:
raise Exception ("Globaltag (parameter 'globaltag') not set in config file")
try:
requestDefault["RequestString"] = parser.get(section, 'requeststring')
except:
raise Exception ("No Request string (parameter 'requeststring') set in the configfile")
try:
rawdataset_str = parser.get(section, 'datasets')
except:
raise Exception ("No RAW datasets (parameter 'datasets') set in the configfile")
rawdataset=commasep2list(rawdataset_str)
try:
repromatrix_ver = parser.get(section, 'reproMatrix_ver')
except:
repromatrix_ver = os.environ["CMSSW_VERSION"]
try:
skimmingMatrix_ver = parser.get(section, 'skimmingMatrix_ver')
except:
skimmingMatrix_ver = os.environ["CMSSW_VERSION"]
try:
runwhitelist_str=parser.get(section, 'run_whitelist')
runwhitelist=commasep2list(runwhitelist_str)
except:
runwhitelist=[]
requestDefault['RunWhitelist']=map(int,runwhitelist)
return {'rawdataset':rawdataset,
'repromatrix_ver':repromatrix_ver,
'skimmingMatrix_ver':skimmingMatrix_ver,
'runwhitelist':runwhitelist,
'globaltag':globaltag}
#-------------------------------------------------------------------------------
if __name__ == "__main__":
options,args = build_parser()
params_dict=get_params(options.reprocfg)
import pprint
print "The parameters are: "
pprint.pprint(params_dict)
if options.prepare_configs:
prepare_configs(params_dict['repromatrix_ver'],
params_dict['skimmingMatrix_ver'],
params_dict['globaltag'])
request(params_dict['rawdataset'],options)