CMS 3D CMS Logo

jobreport.py
Go to the documentation of this file.
1 import xml.etree.cElementTree as ET
2 import re
3 #import lxml.etree.ElementTree as ET
4 
5 
6 class JobReport:
7  def __init__(self):
8  self.fjr = ET.Element("FrameworkJobReport")
9  self.readbranches = ET.SubElement(self.fjr, "ReadBranches")
10  self.performancereport = ET.SubElement(self.fjr, "PerformanceReport")
11  self.performancesummary = ET.SubElement(
12  self.performancereport, "PerformanceSummary", Metric="StorageStatistics")
13  ET.SubElement(self.performancesummary, "Metric",
14  Name="Parameter-untracked-bool-enabled", Value="true")
15  ET.SubElement(self.performancesummary, "Metric",
16  Name="Parameter-untracked-bool-stats", Value="true")
17  ET.SubElement(self.performancesummary, "Metric",
18  Name="Parameter-untracked-string-cacheHint", Value="application-only")
19  ET.SubElement(self.performancesummary, "Metric",
20  Name="Parameter-untracked-string-readHint", Value="auto-detect")
21  ET.SubElement(self.performancesummary, "Metric",
22  Name="ROOT-tfile-read-totalMegabytes", Value="0")
23  ET.SubElement(self.performancesummary, "Metric",
24  Name="ROOT-tfile-write-totalMegabytes", Value="0")
25  # <Metric Name="Parameter-untracked-bool-enabled" Value="true"/>
26  # <Metric Name="Parameter-untracked-bool-stats" Value="true"/>
27  # <Metric Name="Parameter-untracked-string-cacheHint" Value="application-only"/>
28  # <Metric Name="Parameter-untracked-string-readHint" Value="auto-detect"/>
29  # <Metric Name="ROOT-tfile-read-totalMegabytes" Value="0"/>
30  # <Metric Name="ROOT-tfile-write-totalMegabytes" Value="0"/>
31 
32 # likely not needed
33 # <GeneratorInfo>
34 # </GeneratorInfo>
35 
36  def addInputFile(self, filename, eventsRead=1, runsAndLumis={"1": [1]}):
37  infile = ET.SubElement(self.fjr, "InputFile")
38  ET.SubElement(infile, "LFN").text = re.sub(
39  r".*?(/store/.*\.root)(\?.*)?", r"\1", filename)
40  ET.SubElement(infile, "PFN").text = ""
41  ET.SubElement(infile, "Catalog").text = ""
42  ET.SubElement(infile, "InputType").text = "primaryFiles"
43  ET.SubElement(infile, "ModuleLabel").text = "source"
44  ET.SubElement(infile, "InputSourceClass").text = "PoolSource"
45  ET.SubElement(infile, "GUID").text = ""
46  ET.SubElement(infile, "EventsRead").text = "%s" % eventsRead
47  runs = ET.SubElement(infile, "Runs")
48  for r, ls in runsAndLumis.items():
49  run = ET.SubElement(runs, "Run", ID="%s" % r)
50  for l in ls:
51  ET.SubElement(run, "LumiSection", ID="%s" % l)
52 
53  def addOutputFile(self, filename, events=1, runsAndLumis={"1": [1]}):
54  infile = ET.SubElement(self.fjr, "File")
55  ET.SubElement(infile, "LFN").text = ""
56  ET.SubElement(infile, "PFN").text = filename
57  ET.SubElement(infile, "Catalog").text = ""
58  ET.SubElement(infile, "ModuleLabel").text = "NANO"
59  ET.SubElement(infile, "OutputModuleClass").text = "PoolOutputModule"
60  ET.SubElement(infile, "GUID").text = ""
61  ET.SubElement(infile, "DataType").text = ""
62  ET.SubElement(
63  infile, "BranchHash").text = "dc90308e392b2fa1e0eff46acbfa24bc"
64  ET.SubElement(infile, "TotalEvents").text = "%s" % events
65  runs = ET.SubElement(infile, "Runs")
66  for r, ls in runsAndLumis.items():
67  run = ET.SubElement(runs, "Run", ID="%s" % r)
68  for l in ls:
69  ET.SubElement(run, "LumiSection", ID="%s" % l)
70 
71  def save(self, filename="FrameworkJobReport.xml"):
72  tree = ET.ElementTree(self.fjr)
73  tree.write(filename) # , pretty_print=True)
74  pass
def save(self, filename="FrameworkJobReport.xml")
Definition: jobreport.py:71
def addInputFile(self, filename, eventsRead=1, runsAndLumis={"1":[1]})
Definition: jobreport.py:36
def __init__(self)
Definition: jobreport.py:7
def addOutputFile(self, filename, events=1, runsAndLumis={"1":[1]})
Definition: jobreport.py:53