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