ATLAS Offline Software
evaluateDiffRoot.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 # Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
4 
5 from __future__ import print_function
6 
7 from optparse import OptionParser
8 
9 
10 """
11  after a list of tests is extracted from the infile
12  add differences to the dicts
13 """
14 def getResults(infile, test_dict):
15  global debugmode
16  for test in test_dict.keys():
17  for ftype in ['ESD','AOD']:
18  linenr = 0
19  f = open(infile, 'r')
20  doRead = False
21  for line in f:
22  linenr += 1
23  if line.startswith('Py:diff-root INFO old:') and test in line and ftype in line:
24  doRead = True
25  if line.startswith('Py:Acmd'):
26  doRead = False
27  if doRead and ("leaves differ" in line or "WARNING" in line):
28  if line.split('\n')[0] not in test_dict[test][ftype]:
29  test_dict[test][ftype].append(line.split('\n')[0])
30 
31  if debugmode and doRead:
32  print ("DEBUG: %s: %s" %(linenr,line.split('\n')[0]))
33 
34  return test_dict
35 
36 """
37  create initial dict including all tests which have been probed
38 """
39 def getTests(infile, selected_test):
40  test_dict = {}
41  f = open(infile, 'r')
42  for line in f:
43  if "CHANGED" in line or "IDENTICAL" in line:
44  test = line.split()[0]
45  if selected_test and test not in selected_test:
46  continue
47  test_dict[test] = { 'ESD' : [],
48  'AOD' : [],
49  'status' : line.split()[1]}
50  f.close()
51  return test_dict
52 
53 
54 """
55  prints sorted summary of tests
56 """
57 def reportOverview(test_dict):
58  list_sorted = sorted(test_dict.keys())
59  for test in list_sorted:
60  #print ("%20s %s" %(test, test_dict[test]['status']))
61  print ('{0:50} {1:10}'.format(test, test_dict[test]['status']))
62 
63 
64 """
65  prints detailed diff on screen
66 """
67 def reportDiffs(test_dict):
68  list_sorted = sorted(test_dict.keys())
69  for test in list_sorted:
70  if test_dict[test]['status'] == 'IDENTICAL':
71  continue
72  print (test, test_dict[test]['status'])
73  for item in ['ESD','AOD']:
74  print (item)
75  for line in test_dict[test][item]:
76  print (line)
77  print()
78  print()
79 
80 
81 """
82  print all
83 """
84 def printDict(test_dict):
85  print ("Overview:")
86  print ("==========")
87  reportOverview(test_dict)
88  print()
89  print()
90  print()
91  print ("Details")
92  print ("========")
93  reportDiffs(test_dict)
94 
95 
96 
97 
98 """
99  Main function here
100 """
101 if __name__ == "__main__":
102  parser=OptionParser(usage="\n ./sstat \n")
103  parser.add_option("-f","--file",type="string" ,dest="infile" ,default="ESDTAGCOMM_comparison_diffroot_log" ,help="inputfile diff-root")
104  parser.add_option("-t","--test" ,type="string" ,dest="test" ,default=None ,help="condensed output file")
105  #parser.add_option("-o","--outfile" ,type="string" ,dest="outfile" ,default="summary.txt" ,help="condensed output file")
106  parser.add_option("-d", "--debug", action="store_true", dest="verbose", default=False, help="print extra DEBUG messages")
107  (options,args)=parser.parse_args()
108 
109  debugmode = options.verbose
110 
111  infile_name = 'ESDTAGCOMM_comparison_diffroot_log'
112 
113  selected_tests = None
114  if options.test:
115  selected_tests = options.test.split(",")
116 
117  # first create the dict of tests
118  test_dict = getTests(options.infile, selected_tests)
119  # then overwrite the format types with diff info
120  test_dict = getResults(options.infile,test_dict )
121 
122 
123 
124  printDict(test_dict)
python.evaluateDiffRoot.reportDiffs
def reportDiffs(test_dict)
Definition: evaluateDiffRoot.py:67
python.evaluateDiffRoot.getTests
def getTests(infile, selected_test)
Definition: evaluateDiffRoot.py:39
vtune_athena.format
format
Definition: vtune_athena.py:14
dumpHVPathFromNtuple.append
bool append
Definition: dumpHVPathFromNtuple.py:91
python.evaluateDiffRoot.getResults
def getResults(infile, test_dict)
Definition: evaluateDiffRoot.py:14
DerivationFramework::TriggerMatchingUtils::sorted
std::vector< typename T::value_type > sorted(T begin, T end)
Helper function to create a sorted vector from an unsorted one.
Trk::open
@ open
Definition: BinningType.h:40
python.evaluateDiffRoot.printDict
def printDict(test_dict)
Definition: evaluateDiffRoot.py:84
dbg::print
void print(std::FILE *stream, std::format_string< Args... > fmt, Args &&... args)
Definition: SGImplSvc.cxx:70
python.evaluateDiffRoot.reportOverview
def reportOverview(test_dict)
Definition: evaluateDiffRoot.py:57