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 
30  args = parser.parse_args()
31  server = "{0}:{1}".format(args.host, args.port)
32  fOut="log.out"
33  appPath=args.path
34  if args.out:
35  fOut=args.out
36  if not path.exists(args.input) or not path.isfile(args.input):
37  print("Error: input file is not exists")
38  sys.exit()
39  data = {}
40  # Parce athena log and found all folders and other parameters for compare data
41  with open(args.input) as inp_file:
42  while line := inp_file.readline():
43  if line.rstrip().find('/TagInfo<metaOnly/>')>0:
44  lst=line.rstrip().split(',')
45  for e in lst:
46  if e.find('<db>')<0:
47  continue
48  el ={}
49  if e.find('<tag>')>0:
50  sTag=e[e.find('<tag>')+5:]
51  if sTag.find('</tag>')>0:
52  sTag=sTag[:sTag.find('</tag>')]
53  el['tag']=sTag
54  db=e[e.find('<db>')+4:]
55  db=db[:db.find('</db>')]
56  if e.find('<db>')<4:
57  e=e[e.find('</db>')+5:]
58  folder = e[e.find('/'):]
59  if folder.find('<')>-1:
60  folder = folder[:folder.find('<')]
61  elif folder.find(' ')>-1:
62  folder = folder[:folder.find(' ')]
63  else:
64  folder = folder[:folder.find('\'')]
65  el['db']=db.strip()
66  data[folder.strip()]=el
67  if line.rstrip().find('INFO Retrieved object: folder ')>0:
68  st = line.rstrip()[line.rstrip().find('INFO Retrieved object: folder '):]
69  st = st[st.find('/'):]
70  sFolder = st[:st.find(' ')]
71  st= st[st.find('IOV ')+4:]
72  st=st[:st.find(' ')]
73  el = data[sFolder.strip()]
74  el['timestamp']=st
75  data[sFolder]=el
76  print(data)
77  print("List of commands for compare:")
78  # run compare
79  for elem in data.keys():
80  js=data[elem]
81  if 'timestamp' not in js:
82  continue
83  command = appPath + ' -g '+ args.gtag+' -G '+args.gcooltag+ ' -f '+elem + ' -c "'+ js['db']+'" -t ' + js['timestamp']+' -C '+server
84  if 'tag' in js:
85  if js['tag'].find('HEAD')>=0:
86  command +=' --head'
87  command +=' >>'+fOut+' 2>&1'
88  print(command)
89  with open(fOut, 'a') as f:
90  print('Compare folder name:', elem, file=f)
91  print(command,file=f)
92  os.system(command)
93  # parse output of compare folders (CREST and COOL)
94  print("Problem folders:")
95  curFolder=""
96  coolProblem=[]
97  crestProblem=[]
98  difFolder=[]
99  with open(fOut) as log_file:
100  while line := log_file.readline():
101  if line.find('Compare folder name:')>-1:
102  if curFolder != "":
103  js=data[curFolder]
104  command = appPath + ' -g '+ args.gtag+' -G '+args.gcooltag+ ' -f '+ curFolder + ' -c '+ js['db']+' -t ' + js['timestamp']+' -C '+server
105  print(command)
106  curFolder=""
107  curFolder=line.rstrip()[line.rstrip().find('Compare folder name:')+20:]
108  curFolder=curFolder.lstrip()
109  if line.rstrip().find('is the same in COOL and CREST')>0:
110  curFolder=""
111  if line.find('CREST output file problem')>-1:
112  if curFolder != "":
113  crestProblem.append(curFolder)
114  if line.find('COOL output file problem')>-1:
115  if curFolder != "":
116  coolProblem.append(curFolder)
117  if line.rstrip().find('is different in COOL and CREST')>0:
118  fld = line.rstrip()[line.rstrip().find('\"')+1:]
119  fld = fld[:fld.find('\"')]
120  difFolder.append(fld)
121  js=data[fld]
122  command = appPath + ' -g '+ args.gtag+' -G '+args.gcooltag+ ' -f '+ fld + ' -c '+ js['db']+' -t ' + js['timestamp']+' -C '+server
123  print(command)
124  curFolder=""
125  if line.rstrip().find('NO IOVs retrieved for the folder')>0:
126  fld = line.rstrip()[(line.rstrip().find('NO IOVs retrieved for the folder')+32):]
127  fld=fld.lstrip()
128  js=data[fld]
129  command = appPath + ' -g '+ args.gtag+' -G '+args.gcooltag+ ' -f '+ fld + ' -c '+ js['db']+' -t ' + js['timestamp']+' -C '+server
130  print(command)
131  curFolder=""
132  print("Total number of folders:",len(data)," Different data:",len(difFolder)," Cool problem:",len(coolProblem)," Crest problem:",len(crestProblem))
133  if len(difFolder)>0:
134  print("Different data:",difFolder)
135  if len(coolProblem)>0:
136  print("Different data:",coolProblem)
137  if len(crestProblem)>0:
138  print("Different data:",crestProblem)
139 
vtune_athena.format
format
Definition: vtune_athena.py:14
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:26
Trk::open
@ open
Definition: BinningType.h:40
Trk::split
@ split
Definition: LayerMaterialProperties.h:38