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
125
126
127
128
|
#!/usr/bin/env python3
"""
_RunDQMHarvesting_
Test wrapper to generate a harvesting config and push it into cmsRun for
testing with a few input files etc from the command line
"""
import sys
import getopt
import pickle
from Configuration.DataProcessing.GetScenario import getScenario
class RunDQMHarvesting:
def __init__(self):
self.scenario = None
self.dataset = None
self.run = None
self.globalTag = 'UNSPECIFIED::All'
self.inputLFN = None
self.dqmio = None
def __call__(self):
if self.scenario == None:
msg = "No --scenario specified"
raise RuntimeError(msg)
if self.inputLFN == None:
msg = "No --lfn specified"
raise RuntimeError(msg)
if self.run == None:
msg = "No --run specified"
raise RuntimeError(msg)
if self.dataset == None:
msg = "No --dataset specified"
raise RuntimeError(msg)
try:
scenario = getScenario(self.scenario)
except Exception as ex:
msg = "Error getting Scenario implementation for %s\n" % (
self.scenario,)
msg += str(ex)
raise RuntimeError(msg)
print("Retrieved Scenario: %s" % self.scenario)
print("Using Global Tag: %s" % self.globalTag)
print("Dataset: %s" % self.dataset)
print("Run: %s" % self.run)
try:
kwds = {}
if not self.dqmio is None:
kwds['newDQMIO'] = self.dqmio
process = scenario.dqmHarvesting(self.dataset, self.run,
self.globalTag, **kwds)
except Exception as ex:
msg = "Error creating Harvesting config:\n"
msg += str(ex)
raise RuntimeError(msg)
process.source.fileNames.append(self.inputLFN)
pklFile = open("RunDQMHarvestingCfg.pkl", "wb")
psetFile = open("RunDQMHarvestingCfg.py", "w")
try:
pickle.dump(process, pklFile, protocol=0)
psetFile.write("import FWCore.ParameterSet.Config as cms\n")
psetFile.write("import pickle\n")
psetFile.write("handle = open('RunDQMHarvestingCfg.pkl','rb')\n")
psetFile.write("process = pickle.load(handle)\n")
psetFile.write("handle.close()\n")
psetFile.close()
except Exception as ex:
print("Error writing out PSet:")
print(traceback.format_exc())
raise ex
finally:
psetFile.close()
pklFile.close()
cmsRun = "cmsRun -j FrameworkJobReport.xml RunDQMHarvestingCfg.py"
print("Now do:\n%s" % cmsRun)
if __name__ == '__main__':
valid = ["scenario=", "run=", "dataset=",
"global-tag=", "lfn=", "dqmio"]
usage = """RunDQMHarvesting.py <options>"""
try:
opts, args = getopt.getopt(sys.argv[1:], "", valid)
except getopt.GetoptError as ex:
print(usage)
print(str(ex))
sys.exit(1)
harvester = RunDQMHarvesting()
for opt, arg in opts:
if opt == "--scenario":
harvester.scenario = arg
if opt == "--global-tag":
harvester.globalTag = arg
if opt == "--lfn" :
harvester.inputLFN = arg
if opt == "--run":
harvester.run = arg
if opt == "--dataset":
harvester.dataset = arg
if opt == "--dqmio":
harvester.dqmio = True
harvester()
|