ATLAS Offline Software
Loading...
Searching...
No Matches
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
7import sys
8import os.path
9import argparse
10
11from os import path
12
13if __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', action=argparse.BooleanOptionalAction, help='Set debug output')
30
31 args = parser.parse_args()
32 server = "{0}:{1}".format(args.host, args.port)
33 fOut="log.out"
34 appPath=args.path
35 if args.out:
36 fOut=args.out
37 if not path.exists(args.input) or not path.isfile(args.input):
38 print("Error: input file is not exists")
39 sys.exit()
40 data = {}
41 st=""
42 noUsedData=[]
43 # Parce athena log and found all folders and other parameters for compare data
44 with open(args.input) as inp_file:
45 while line := inp_file.readline():
46 if line.rstrip().find('/TagInfo<metaOnly/>')>0:
47 lst=line.rstrip().split(',')
48 for e in lst:
49 if e.find('<db>')<0:
50 continue
51 el ={}
52 if e.find('<tag>')>0:
53 sTag=e[e.find('<tag>')+5:]
54 if sTag.find('</tag>')>0:
55 sTag=sTag[:sTag.find('</tag>')]
56 el['tag']=sTag
57 db=e[e.find('<db>')+4:]
58 db=db[:db.find('</db>')]
59 if e.find('<db>')<4:
60 e=e[e.find('</db>')+5:]
61 folder = e[e.find('/'):]
62 if folder.find('<')>-1:
63 folder = folder[:folder.find('<')]
64 elif folder.find(' ')>-1:
65 folder = folder[:folder.find(' ')]
66 else:
67 folder = folder[:folder.find('\'')]
68 el['db']=db.strip()
69 data[folder.strip()]=el
70 if line.rstrip().find('Using tag ')>0:
71 st = line.rstrip()[line.rstrip().find('Using tag ')+10:]
72 sTag = st[:st.find(' ')]
73 if st.rstrip().find('for folder ')>0:
74 st = st.rstrip()[st.rstrip().find('for folder '):]
75 st = st[st.find('/'):]
76 sFolder = st.strip()
77 el = data[sFolder.strip()]
78 el['tag']=sTag
79 data[sFolder.strip()]=el
80 if line.rstrip().find(' is requested but no data retrieved')>0:
81 st = line.rstrip()[:line.rstrip().find(' is requested but no data retrieved')]
82 st = st[st.find('WARNING Folder')+14:]
83 noUsedData.append(st.strip())
84 if line.rstrip().find('Retrieved object: folder ')>0:
85 st = line.rstrip()[line.rstrip().find('Retrieved object: folder '):]
86 st = st[st.find('/'):]
87 sFolder = st[:st.find(' ')]
88 st= st[st.find('IOV ')+4:]
89 st=st[:st.find(' ')]
90 el = data[sFolder.strip()]
91 el['timestamp']=st
92 data[sFolder.strip()]=el
93 if args.debug:
94 print(data)
95 print("List of commands for compare:")
96 # run compare
97 for elem in data.keys():
98 js=data[elem]
99 if 'timestamp' not in js:
100 continue
101 command = appPath + ' -g '+ args.gtag+' -G '+args.gcooltag+ ' -f '+elem + ' -c "'+ js['db']+'" -t ' + js['timestamp']+' -C '+server
102 if 'tag' in js:
103 if js['tag'].find('HEAD')>=0:
104 command +=' --head'
105 else:
106 command +=' -T '+js['tag']
107 command +=' >>'+fOut+' 2>&1'
108 print(command)
109 with open(fOut, 'a') as f:
110 print('Compare folder name:', elem, file=f)
111 print(command,file=f)
112 os.system(command)
113 #parse output of compare folders (CREST and COOL)
114 print("Problem folders:")
115 curFolder=""
116 coolProblem=[]
117 crestProblem=[]
118 unknowProblem=[]
119 difFolder=[]
120 correctFolder=[]
121 allFolder=[]
122 isCOOL=False
123 isCREST=False
124 with open(fOut) as log_file:
125 while line := log_file.readline():
126 if line.find('Compare folder name:')>-1:
127 if curFolder != "":
128 js=data[curFolder]
129 command = appPath + ' -g '+ args.gtag+' -G '+args.gcooltag+ ' -f '+ curFolder + ' -c '+ js['db']+' -t ' + js['timestamp']+' -C '+server
130 if 'tag' in js:
131 if js['tag'].find('HEAD')>=0:
132 command +=' --head'
133 else:
134 command +=' -T '+js['tag']
135 print(command)
136 if isCREST:
137 crestProblem.append(curFolder)
138 elif isCOOL:
139 coolProblem.append(curFolder)
140 else:
141 unknowProblem.append(curFolder)
142 curFolder=""
143 curFolder=line.rstrip()[line.rstrip().find('Compare folder name:')+20:]
144 curFolder=curFolder.lstrip()
145 allFolder.append(curFolder)
146 elif line.rstrip().find('is the same in COOL and CREST')>0:
147 correctFolder.append(curFolder)
148 curFolder=""
149 elif line.rstrip().find('Start COOL dump:')>-1:
150 isCOOL=True
151 isCREST=False
152 elif line.rstrip().find('Start CREST dump:')>-1:
153 isCOOL=False
154 isCREST=True
155 elif line.find('CREST output file problem')>-1:
156 if curFolder != "":
157 crestProblem.append(curFolder)
158 elif line.find('COOL output file problem')>-1:
159 if curFolder != "":
160 coolProblem.append(curFolder)
161 elif line.rstrip().find('is different in COOL and CREST')>0:
162 fld = line.rstrip()[line.rstrip().find('\"')+1:]
163 fld = fld[:fld.find('\"')]
164 difFolder.append(fld)
165 js=data[fld]
166 command = appPath + ' -g '+ args.gtag+' -G '+args.gcooltag+ ' -f '+ fld + ' -c '+ js['db']+' -t ' + js['timestamp']+' -C '+server
167 if 'tag' in js:
168 if js['tag'].find('HEAD')>=0:
169 command +=' --head'
170 else:
171 command +=' -T '+js['tag']
172 print(command)
173 curFolder=""
174 unCompared=data.keys()-allFolder
175 compList=set(unCompared)-set(noUsedData)
176 print("Total number of folders in logs:",len(data),"; Total number of folders which compare (used):",len(allFolder), "; Total number of unread folders:", len(noUsedData),"; Correct folders:",len(correctFolder),"; Different folders:",len(difFolder),"; COOL problems:",len(coolProblem),"; CREST problems:",len(crestProblem), "; Unknown problems:", len(unknowProblem))
177 if len(difFolder)>0:
178 print("Different data:",difFolder)
179 if len(coolProblem)>0:
180 print("COOL problem folders:",coolProblem)
181 if len(crestProblem)>0:
182 print("CREST problem folders:",crestProblem)
183 if len(unknowProblem)>0:
184 print("Unknown problem folders:",unknowProblem)
185 if len(compList)>0:
186 if len(unCompared):
187 print("Incomparable folders:",unCompared)
188 if len(noUsedData)>0:
189 print("Unread (Unused) folders:",noUsedData)
190 elif len(noUsedData)>0:
191 print("Unread (Unused) folders:",noUsedData)
192 if len(correctFolder)>0 and args.debug:
193 print("Correct folders:",correctFolder)
194 if len(allFolder)>0 and args.debug:
195 print("Full folder list:",allFolder)
196 if args.debug:
197 print("Total list folders in log:",list(data.keys()))
198
void print(char *figname, TCanvas *c1)
STL class.
std::string find(const std::string &s)
return a remapped string
Definition hcg.cxx:138
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:177