ATLAS Offline Software
getProblemFolderFromLogs.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2 
3 
6 
7 import sys
8 import os.path
9 import argparse
10 
11 from os import path
12 
13 if __name__ == "__main__":
14  # Parse arguments
15  parser = argparse.ArgumentParser(description='Coolr browser.', add_help=False)
16  parser.add_argument('--input', required=True,help='Input file in text folrat. It is output of athena job. It require has lines with info about load data: INFO Retrieved object: folder ')
17  parser.add_argument('--gtag', required=True,
18  help='Global tag for CREST')
19  parser.add_argument('--gcooltag', required=True,
20  help='Global tag for COOL')
21  parser.add_argument('--host', default='http://crest-j23.cern.ch',
22  help='Host of the CREST service (default: http://crest-j23.cern.ch)')
23  parser.add_argument('--port', default='8080',
24  help='Port of the CREST service (default: 8080)')
25  parser.add_argument('--out', default='log.out',
26  help='Out file for logs (default: log.out)')
27  parser.add_argument('--path', default='cool_crest_compare',
28  help='Path to compare (default: cool_crest_compare)')
29  parser.add_argument('--debug', default='',
30  help='Set debug output')
31 
32  args = parser.parse_args()
33  server = "{0}:{1}".format(args.host, args.port)
34  fOut="log.out"
35  isDebug=False
36  if args.debug:
37  isDebug=bool(args.debug)
38  appPath=args.path
39  if args.out:
40  fOut=args.out
41  if not path.exists(args.input) or not path.isfile(args.input):
42  print("Error: input file is not exists")
43  sys.exit()
44  data = {}
45  st=""
46  # Parce athena log and found all folders and other parameters for compare data
47  with open(args.input) as inp_file:
48  while line := inp_file.readline():
49  if line.rstrip().find('/TagInfo<metaOnly/>')>0:
50  lst=line.rstrip().split(',')
51  for e in lst:
52  if e.find('<db>')<0:
53  continue
54  el ={}
55  if e.find('<tag>')>0:
56  sTag=e[e.find('<tag>')+5:]
57  if sTag.find('</tag>')>0:
58  sTag=sTag[:sTag.find('</tag>')]
59  el['tag']=sTag
60  db=e[e.find('<db>')+4:]
61  db=db[:db.find('</db>')]
62  if e.find('<db>')<4:
63  e=e[e.find('</db>')+5:]
64  folder = e[e.find('/'):]
65  if folder.find('<')>-1:
66  folder = folder[:folder.find('<')]
67  elif folder.find(' ')>-1:
68  folder = folder[:folder.find(' ')]
69  else:
70  folder = folder[:folder.find('\'')]
71  el['db']=db.strip()
72  data[folder.strip()]=el
73  if line.rstrip().find('Retrieved object: folder ')>0:
74  st = line.rstrip()[line.rstrip().find('Retrieved object: folder '):]
75  st = st[st.find('/'):]
76  sFolder = st[:st.find(' ')]
77  st= st[st.find('IOV ')+4:]
78  st=st[:st.find(' ')]
79  el = data[sFolder.strip()]
80  el['timestamp']=st
81  data[sFolder.strip()]=el
82  if isDebug:
83  print(data)
84  print("List of commands for compare:")
85  # run compare
86  for elem in data.keys():
87  js=data[elem]
88  if 'timestamp' not in js:
89  continue
90  command = appPath + ' -g '+ args.gtag+' -G '+args.gcooltag+ ' -f '+elem + ' -c "'+ js['db']+'" -t ' + js['timestamp']+' -C '+server
91  if 'tag' in js:
92  if js['tag'].find('HEAD')>=0:
93  command +=' --head'
94  command +=' >>'+fOut+' 2>&1'
95  print(command)
96  with open(fOut, 'a') as f:
97  print('Compare folder name:', elem, file=f)
98  print(command,file=f)
99  os.system(command)
100  #parse output of compare folders (CREST and COOL)
101  print("Problem folders:")
102  curFolder=""
103  coolProblem=[]
104  crestProblem=[]
105  difFolder=[]
106  correctFolder=[]
107  allFolder=[]
108  with open(fOut) as log_file:
109  while line := log_file.readline():
110  if line.find('Compare folder name:')>-1:
111  if curFolder != "":
112  js=data[curFolder]
113  command = appPath + ' -g '+ args.gtag+' -G '+args.gcooltag+ ' -f '+ curFolder + ' -c '+ js['db']+' -t ' + js['timestamp']+' -C '+server
114  print(command)
115  curFolder=""
116  curFolder=line.rstrip()[line.rstrip().find('Compare folder name:')+20:]
117  curFolder=curFolder.lstrip()
118  allFolder.append(curFolder)
119  if line.rstrip().find('is the same in COOL and CREST')>0:
120  correctFolder.append(curFolder)
121  curFolder=""
122  if line.find('CREST output file problem')>-1:
123  if curFolder != "":
124  crestProblem.append(curFolder)
125  if line.find('COOL output file problem')>-1:
126  if curFolder != "":
127  coolProblem.append(curFolder)
128  if line.rstrip().find('is different in COOL and CREST')>0:
129  fld = line.rstrip()[line.rstrip().find('\"')+1:]
130  fld = fld[:fld.find('\"')]
131  difFolder.append(fld)
132  js=data[fld]
133  command = appPath + ' -g '+ args.gtag+' -G '+args.gcooltag+ ' -f '+ fld + ' -c '+ js['db']+' -t ' + js['timestamp']+' -C '+server
134  print(command)
135  curFolder=""
136  print("Total number of folders in logs:",len(data)," Total number of folders which compare (used):",len(allFolder)," Correct folders:",len(correctFolder)," Different folders:",len(difFolder)," COOL problems:",len(coolProblem)," CREST problems:",len(crestProblem))
137  if len(difFolder)>0:
138  print("Different data:",difFolder)
139  if len(coolProblem)>0:
140  print("COOL problem folders:",coolProblem)
141  if len(crestProblem)>0:
142  print("CREST problem folders:",crestProblem)
143  if len(correctFolder)>0 and isDebug:
144  print("Correct folders:",correctFolder)
145  if len(allFolder)>0 and isDebug:
146  print("Full folder list:",allFolder)
147  if isDebug:
148  print("Total list folders in log:",list(data.keys()))
149 
vtune_athena.format
format
Definition: vtune_athena.py:14
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:138
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:26
Trk::open
@ open
Definition: BinningType.h:40
xAOD::bool
setBGCode setTAP setLVL2ErrorBits bool
Definition: TrigDecision_v1.cxx:60
Trk::split
@ split
Definition: LayerMaterialProperties.h:38