1 |
import os, common, string
|
2 |
from Actor import *
|
3 |
from crab_util import *
|
4 |
|
5 |
class Reporter(Actor):
|
6 |
""" A class to report a short summary of the info of a task, including what
|
7 |
is needed for user analysis, such as #events requestes/done, integrated
|
8 |
lumi and so one.
|
9 |
"""
|
10 |
def __init__(self, cfg_params):
|
11 |
self.cfg_params = cfg_params
|
12 |
return
|
13 |
|
14 |
def run(self):
|
15 |
"""
|
16 |
The main method of the class: report status of a task
|
17 |
"""
|
18 |
common.logger.debug(5, "Reporter::run() called")
|
19 |
task = common._db.getTask()
|
20 |
#print task
|
21 |
print "\n----------------------------\n"
|
22 |
print "Dataset: ",task['dataset']
|
23 |
from ProdCommon.FwkJobRep.ReportParser import readJobReport
|
24 |
possible_status = [ 'Created',
|
25 |
'Undefined',
|
26 |
'Submitting',
|
27 |
'Submitted',
|
28 |
'Waiting',
|
29 |
'Ready',
|
30 |
'Scheduled',
|
31 |
'Running',
|
32 |
'Done',
|
33 |
'Killing',
|
34 |
'Killed',
|
35 |
'Aborted',
|
36 |
'Unknown',
|
37 |
'Done (Failed)',
|
38 |
'Cleared',
|
39 |
'retrieved'
|
40 |
]
|
41 |
eventsRead=0
|
42 |
filesRead=0
|
43 |
for job in task.getJobs():
|
44 |
# get FJR filename
|
45 |
fjr=task['outputDirectory']+job['outputFiles'][-1]
|
46 |
#print fjr
|
47 |
jobReport = readJobReport(fjr)
|
48 |
if len(jobReport)>0:
|
49 |
inputFiles=jobReport[0].inputFiles
|
50 |
for inputFile in inputFiles:
|
51 |
runs=inputFile.runs
|
52 |
#print [inputFile[it] for it in ['LFN','EventsRead']]
|
53 |
# print "FileIn :",inputFile['LFN'],": Events",inputFile['EventsRead']
|
54 |
# for run in runs.keys():
|
55 |
# print "Run",run,": lumi sections",runs[run]
|
56 |
filesRead+=1
|
57 |
eventsRead+=int(inputFile['EventsRead'])
|
58 |
|
59 |
#print jobReport[0].inputFiles,'\n'
|
60 |
else:
|
61 |
print 'no FJR avaialble'
|
62 |
#print "--------------------------"
|
63 |
print "Total Events read: ",eventsRead
|
64 |
print "Total Files read: ",filesRead
|
65 |
print "Total Jobs : ",len(task.getJobs())
|
66 |
list_ID={}
|
67 |
for st in possible_status:
|
68 |
list_ID = common._db.queryAttrRunJob({'statusScheduler':st},'jobId')
|
69 |
if (len(list_ID)>0):
|
70 |
print " # Jobs:",str(st),":",len(list_ID)
|
71 |
pass
|
72 |
print "\n----------------------------\n"
|
73 |
|
74 |
return
|