6 import optparse, sys, math, subprocess
7 from collections
import OrderedDict
9 parser = optparse.OptionParser(usage=__doc__)
10 parser.add_option(
"-i",
"--input", default=
"-", dest=
"INPUT_FILE", metavar=
"PATH", help=
"input logfile")
11 parser.add_option(
"-N",
"--Ntotal", default=0, dest=
"TOTAL_EVENTS", metavar=
"", help=
"Total number of events")
12 parser.add_option(
"-s",
"--nosvn", action=
"store_true", dest=
"NO_SVN", default=
False, help=
"Turn off any checks that require SVN access")
13 parser.add_option(
"-c",
"--nocolour", action=
"store_true", dest=
"NO_COLOUR", default=
False, help=
"Turn off colour for copying to file")
15 opts, fileargs = parser.parse_args()
20 if opts.INPUT_FILE==
"-":
28 "including file \"MC15JobOptions/":[],
29 "including file \"MC15.":[]
38 'Events passing all checks and written':[]
42 'Weighted Filter Efficiency':[],
43 'Filter Efficiency':[]
56 'contactPhysicist':[],
59 'cross-section (nb)':[],
70 'snapshot_post_fin':[],
76 file=
open(opts.INPUT_FILE,
"r")
77 lines=file.readlines()
82 checkLine(line,
'Py:Athena',JOsDict,
'INFO')
84 checkLine(line,
'MetaData',metaDataDict,
'=')
85 checkLine(line,
'Py:Generate',generateDict,
'=')
87 checkLine(line,
'Py:PerfMonSvc',perfMonDict,
':')
88 checkLine(line,
'PMonSD',perfMonDict,
'---')
90 checkLine(line,
'TestHepMC',testHepMCDict,
'=')
91 checkLine(line,
'Py:EvgenFilterSeq',evgenFilterSeqDict,
'=')
92 checkLine(line,
'CountHepMC',countHepMCDict,
'=')
93 checkLine(line,
'SimTimeEstimate',simTimeEstimateDict,
'|')
100 print(
"---------------------")
101 print(
"jobOptions and release:")
102 print(
"---------------------")
107 JOsErrors.append(
"including file \"MC15JobOptions/")
108 JOsErrors.append(
"including file \"MC15.")
112 if not len(JOsDict[
"including file \"MC15JobOptions/"]):
113 JOsErrors.append(
"including file \"MC15JobOptions/")
114 if not len(JOsDict[
"including file \"MC15."]):
115 JOsErrors.append(
"including file \"MC15.")
122 pieces=jo.replace(
'.py',
'').
split(
'.')
123 if len(pieces)
and pieces[0]==
'MC15':
128 DSIDxxx=
"DSID"+DSID[:3]+
"xxx"
131 logerr(
"",
"ERROR: More than one \"top\" JO file found!")
132 raise RuntimeError(
"More than one \"top\" JO file found")
136 svnexcomm=
"svn ls --depth infinity svn+ssh://mcfayden@svn.cern.ch/reps/atlasoff/Generators/MC15JobOptions/trunk/"
137 retcode = subprocess.Popen(svnexcomm, shell=
True,stdout=subprocess.PIPE,stderr=subprocess.PIPE).communicate()
138 svnJOs=retcode[0].
split()
141 logerr(
"",
"ERROR: Problem reading from SVN")
142 raise RuntimeError(
"Problem reading from SVN")
146 if "share/%s/%s"%(DSIDxxx,jo)
in retcode[0]:
149 logerr(
"",jo+
" ERROR <-- jobOptions not found in SVN!")
151 indices = [i
for i,s
in enumerate(svnJOs)
if "/"+jo
in s]
156 logerr(
"",jo+
" - jobOptions not found in SVN!")
158 logwarn(
"",jo+
" - multiple instances of jobOptions not found in SVN!")
160 logwarn(
"",jo+
" --> %s"%svnJOs[ix])
168 if not len(JOsDict[
'using release']):
169 JOsErrors.append(JOsDict[
'using release'])
172 tmp=JOsDict[name][0].
replace(
'using release',
'').strip().
split()[0]
173 val=tmp.replace(
'[',
'').
replace(
']',
'')
176 if checkBlackList(val.split(
'-')[0],val.split(
'-')[1],
'MC15JobOptions',
".",JOsList) :
177 logerr(
'- '+name+
' = ',
"".
join(val)+
" <-- ERROR: Cache is blacklisted for this generator")
186 print(
"---------------------")
187 print(
"MISSING JOs:")
189 if i ==
"including file \"MC15.":
191 logwarn(
"",
"INFO: local version of JOs used?")
193 logerr(
"",
"ERROR: %s is missing!"%i)
199 print(
"---------------------")
200 print(
"Generate params:")
201 print(
"---------------------")
202 for key
in generateDict:
204 val=generateDict[key]
207 generate.append(name)
209 if key ==
'minevents':
210 tmp=
str(val[2]).
split(
'#')[0].strip()
211 generateDict[
'minevents']=tmp
216 if len(generateErrors):
217 print(
"---------------------")
218 print(
"MISSING Generate params:")
219 for i
in generateErrors:
220 logerr(
"",
"ERROR: %s is missing!"%i)
226 print(
"---------------------")
228 print(
"---------------------")
229 for key
in metaDataDict:
231 val=metaDataDict[key]
233 metaDataErrors.append(name)
235 if name==
"contactPhysicist":
237 logerr(
'- '+name+
' = ',
"".
join(val)+
" <-- ERROR: No email found")
242 if len(metaDataErrors):
243 print(
"---------------------")
244 print(
"MISSING Metadata:")
245 for i
in metaDataErrors:
247 loginfo(
"INFO:",
"%s is missing"%i)
249 logerr(
"",
"ERROR: %s is missing!"%i)
255 print(
"---------------------")
256 print(
"Performance metrics:")
257 print(
"---------------------")
258 for key
in perfMonDict:
262 perfMonErrors.append(name)
265 if key ==
'snapshot_post_fin':
269 tmp=tmp/(1000.*60.*60.)
276 if key ==
'last -evt vmem':
277 name =
'Virtual memory'
285 if len(perfMonErrors):
286 print(
"---------------------")
287 print(
"MISSING Performance metric:")
288 for i
in perfMonErrors:
289 print(
"ERROR: %s is missing!"%i)
295 'TestHepMC':testHepMCDict,
296 'EvgenFilterSeq':evgenFilterSeqDict,
297 'CountHepMC':countHepMCDict,
298 'SimTimeEstimate':simTimeEstimateDict
303 print(
"---------------------")
304 print(
"Event tests:")
305 print(
"---------------------")
306 for dictkey
in testDict:
307 for key
in testDict[dictkey]:
309 val=testDict[dictkey][key]
311 testErrors.append(
"%s %s"%(dictkey,name))
314 if dictkey==
"CountHepMC":
315 allowed_minevents_lt1000 = [1, 2, 5, 10, 20, 25, 50, 100, 200, 500]
316 if int(val[0])%1000!=0
and not int(val[0])
in allowed_minevents_lt1000:
317 logerr(
'- '+dictkey+
" "+name+
' = ',
"".
join(val)+
" <-- ERROR: Not an acceptable number of events for production")
318 elif int(val[0]) !=
int(generateDict[
'minevents']):
319 logerr(
'- '+dictkey+
" "+name+
' = ',
"".
join(val)+
" <-- ERROR: This is not equal to minevents")
325 if dictkey==
"EvgenFilterSeq":
327 logerr(
'- '+dictkey+
" "+name+
' = ',
"".
join(val))
332 if dictkey==
"TestHepMC" and name==
"Efficiency":
334 logerr(
'- '+dictkey+
" "+name+
' = ',
"".
join(val))
343 print(
"---------------------")
344 print(
"Failed tests:")
346 if i ==
"SimTimeEstimate RUN INFORMATION":
347 logwarn(
"",
"WARNING: %s is missing!"%i)
349 logerr(
"",
"ERROR: %s is missing!"%i)
353 if opts.TOTAL_EVENTS:
356 print(
"---------------------")
359 if opts.TOTAL_EVENTS:
360 xs_nb=
float(metaDataDict[
'cross-section (nb)'][0])
361 eff_lumi_fb=
float(opts.TOTAL_EVENTS)/(1.E+06*xs_nb)
362 if eff_lumi_fb > 1000.:
363 logwarn(
"- Effective lumi (fb-1):",
str(eff_lumi_fb))
364 elif eff_lumi_fb < 40.:
365 logwarn(
"- Effective lumi (fb-1):",
str(eff_lumi_fb))
367 loggood(
"- Effective lumi (fb-1):",
str(eff_lumi_fb))
368 minevents=
int(generateDict[
'minevents'])
370 loginfo(
"- Number of jobs:",
int(opts.TOTAL_EVENTS)/minevents)
372 if not opts.TOTAL_EVENTS
or opts.NO_SVN:
375 print(
"---------------------")
377 if not opts.TOTAL_EVENTS:
378 logwarn(
"",
"WARNING: --Ntotal (-N) flag is not used - total number of events not given - impossible to calculated effective lumi.")
380 logwarn(
"",
"WARNING: --nosvn (-x) flag is used - could not check that SVN JOs are registered or whether release is blacklisted.")
389 if len(JOsDict[
"including file \"MC15JobOptions/"]):
390 liststr+=
"|".
join(JOsDict[
"including file \"MC15JobOptions/"]).
replace(
"nonStandard/",
"")
391 if len(JOsDict[
"including file \"MC15."]):
392 liststr+=
"|".
join(JOsDict[
"including file \"MC15."].
replace(
"nonStandard/",
""))
393 liststr=liststr.replace(
'MC15JobOptions/',
'').
replace(
'"',
'').
replace(
'including file',
'').
replace(
' ',
'')
394 tmplist=liststr.split(
'|')
401 user = getpass.getuser()
409 blacklist =
'svn export svn+ssh://svn.cern.ch/reps/atlasoff/Generators/'+MCJobOptions+
'/trunk/common/BlackList_caches.txt'
410 tmpblackfile =
"%s/BlackList_caches.txt" % (outnamedir)
413 if 'MC15' in MCJobOptions :
414 svnexcomm=
'%s %s' % (blacklist,tmpblackfile)
415 retcode = subprocess.Popen(svnexcomm, shell=
True,stdout=subprocess.PIPE,stderr=subprocess.PIPE).communicate()
416 if retcode[1].
find(
"exist") != -1
or retcode[1].
find(
"cannot") != -1 :
417 logerr(
"",
"export failed= BlackList_caches.txt" )
420 bfile =
open(tmpblackfile)
428 if any( bad[2]
in s
for s
in aJOs )
and branch
in bad[0]:
431 for i,c
in enumerate(cache.split(
'.')):
432 if not c == bad[1].
split(
'.')[i]:
448 if not opts.NO_COLOUR:
472 print(
str(out1),bcolors.OKBLUE +
str(out2) + bcolors.ENDC)
474 print(
str(out1),bcolors.OKGREEN +
str(out2) + bcolors.ENDC)
476 print(
str(out1),bcolors.FAIL +
str(out2) + bcolors.ENDC)
478 print(
str(out1),bcolors.WARNING +
str(out2) + bcolors.ENDC)
482 if lineIdentifier
in line:
485 if len(line.split(splitby))==0:
486 raise RuntimeError(
"Found bad entry %s"%line)
488 thing=
"".
join(line.split(lineIdentifier)[1].
split(splitby)[1:]).strip()
493 if __name__ ==
"__main__":