ATLAS Offline Software
runDiffRootOnChanged.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 
6 import os
7 from optparse import OptionParser
8 
9 """
10  simple script to run diff-root only on tests which show differences in diff-pool
11  either create a diff pool by hand first or just download the ESDTAGCOMM_comparison_log
12  of the current nightly:
13 
14  wget https://atlas-rtt.cern.ch/prod/tct/rel_3/20.1.X.Y-VAL/build/x86_64-slc6-gcc48-opt/offline/Tier0ChainTests/ESDTAGCOMM_comparison/ESDTAGCOMM_comparison_log
15 
16  then execute the script with the comparison log:
17 
18  ./runDiffRootOnChanged.py -f ESDTAGCOMM_comparison_log
19 
20 """
21 
22 
23 
24 """
25  first evaluate last 40 lines of the diff-pool log
26  and extract tests with changed
27 
28 """
29 def read_diff_pool_log(filename):
30  changed_tests = []
31  f = open(filename, 'r')
32  lines = f.readlines(); f.close()
33  for line in lines[-40:]:
34  if "CHANGED" in line:
35  changed_tests.append(line.split()[0])
36  return changed_tests
37 
38 
39 """
40  exectute diff-root command
41 """
42 def diff_root(pool_list,test,ftype):
43  outfile = "%s_%s.log" %(test, ftype)
44  command = "acmd.py diff-root %s %s --error-mode resilient --ignore-leaves RecoTimingObj_p1_HITStoRDO_timings RecoTimingObj_p1_RAWtoESD_mems RecoTimingObj_p1_RAWtoESD_timings RAWtoESD_mems RAWtoESD_timings ESDtoAOD_mems ESDtoAOD_timings HITStoRDO_timings --entries 10 >> %s" %(pool_list[0], pool_list[1], outfile)
45  if options.dryrun:
46  print (command)
47  else:
48  os.system(command)
49 
50 
51 
52 """
53  since some pool files are located on eos others are on afs
54  this little hack is needed to get all files for the comparison
55 """
56 def guessSecond(ESD_list):
57  ref = ESD_list[0]
58  repl = "rel%s" %(ref.split("rel")[1].split("/")[0])
59  newversion = "rel_%i" %(int(repl.split("_")[1])+1)
60  filename = ref.replace(repl,newversion)
61  if os.path.isfile(filename):
62  ESD_list.append(filename)
63  return ESD_list
64 
65 """
66  extract path to pool files from diff-pool log
67  skip tests with failing tests
68  then execute diff_root for every pair
69 """
70 def get_test_pool_files(logfile, tests):
71  for test in tests:
72  AOD_list = []
73  ESD_list = []
74  print()
75  print()
76  print (test)
77  f = open(logfile, 'r')
78  for line in f:
79  if ".pool.root" in line and "open" in line and test in line:
80  if "AOD" in line:
81  AOD_list.append( line.split('[')[1].split(']')[0])
82  elif "ESD" in line:
83  ESD_list.append( line.split('[')[1].split(']')[0])
84  f.close()
85  AOD_list = list(set(AOD_list))
86  ESD_list = list(set(ESD_list))
87  if len(ESD_list) == 1:
88  ESD_list = guessSecond(ESD_list)
89  if len(AOD_list) == 1:
90  AOD_list = guessSecond(AOD_list)
91 
92  if len(ESD_list) < 2:
93  print ("ERROR missing ESD file for diff-root comparison" )
94  else:
95  print ("INFO evaluate ESD diff-root")
96  diff_root(ESD_list, test, "ESD")
97 
98  if len(AOD_list) < 2:
99  print ("ERROR missing AOD file for diff-root comparison")
100  else:
101  print ("INFO evaluate AOD diff-root")
102  diff_root(AOD_list, test, "AOD")
103 
104 
105 
106 def test_pool_files(logfile, tests):
107  rels = ["rel_2","rel_3"]
108  for test in tests:
109  path = "/afs/cern.ch/atlas/project/RTT/prod/Results/tct/REL/20.1.X.Y-VAL/build/x86_64-slc6-gcc48-opt/offline/Tier0ChainTests/%s/" %(test)
110  AOD_list = []
111  ESD_list = []
112  print()
113  print()
114  print (test)
115  for rel in rels:
116  aod = path.replace("REL",rel)+"myAOD.pool.root"
117  esd = path.replace("REL",rel)+"myESD.pool.root"
118  if os.path.isfile(aod):
119  AOD_list.append(aod)
120  if os.path.isfile(esd):
121  ESD_list.append(esd)
122  AOD_list = list(set(AOD_list))
123  ESD_list = list(set(ESD_list))
124  if len(ESD_list) < 2:
125  print ("ERROR missing ESD file for diff-root comparison" )
126  else:
127  print ("INFO evaluate ESD diff-root")
128  diff_root(ESD_list, test, "ESD")
129 
130  if len(AOD_list) < 2:
131  print ("ERROR missing AOD file for diff-root comparison")
132  else:
133  print ("INFO evaluate AOD diff-root")
134  diff_root(AOD_list, test, "AOD")
135 
136 parser=OptionParser(usage="\n ./runDiffRootOnChanged.py --file <file name with full diff-pool log > \n")
137 parser.add_option("-f","--file" ,type="string" ,dest="filename" ,default="none" ,help="diff pool log file")
138 parser.add_option("-d","--dryRun", action="store_true" ,dest="dryrun" ,default=False ,help="only dumps commands on screen")
139 
140 
141 (options,args)=parser.parse_args()
142 logfile = options.filename
143 tests = read_diff_pool_log(logfile)
144 
145 
146 print ("INFO following tests changed")
147 for test in tests:
148  print (" ",test)
149 if tests:
150  get_test_pool_files(logfile, tests)
151 else:
152  print ("All Tests are identical no further checks needed")
python.runDiffRootOnChanged.test_pool_files
def test_pool_files(logfile, tests)
Definition: runDiffRootOnChanged.py:106
python.runDiffRootOnChanged.guessSecond
def guessSecond(ESD_list)
Definition: runDiffRootOnChanged.py:56
python.runDiffRootOnChanged.get_test_pool_files
def get_test_pool_files(logfile, tests)
Definition: runDiffRootOnChanged.py:70
python.runDiffRootOnChanged.diff_root
def diff_root(pool_list, test, ftype)
Definition: runDiffRootOnChanged.py:42
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
CxxUtils::set
constexpr std::enable_if_t< is_bitmask_v< E >, E & > set(E &lhs, E rhs)
Convenience function to set bits in a class enum bitmask.
Definition: bitmask.h:232
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:26
Trk::open
@ open
Definition: BinningType.h:40
python.runDiffRootOnChanged.read_diff_pool_log
def read_diff_pool_log(filename)
Definition: runDiffRootOnChanged.py:29
python.CaloAddPedShiftConfig.int
int
Definition: CaloAddPedShiftConfig.py:45
Trk::split
@ split
Definition: LayerMaterialProperties.h:38