1 |
slacapra |
1.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 |
spiga |
1.4 |
common.logger.debug( "Reporter::run() called")
|
19 |
slacapra |
1.1 |
task = common._db.getTask()
|
20 |
slacapra |
1.2 |
#print self.cfg_params
|
21 |
slacapra |
1.1 |
print "\n----------------------------\n"
|
22 |
|
|
print "Dataset: ",task['dataset']
|
23 |
slacapra |
1.2 |
if self.cfg_params.has_key('USER.copy_data') and int(self.cfg_params['USER.copy_data'])==1:
|
24 |
|
|
print "Remote output :"
|
25 |
|
|
## TODO: SL should come from jobDB!
|
26 |
|
|
from PhEDExDatasvcInfo import PhEDExDatasvcInfo
|
27 |
|
|
stageout = PhEDExDatasvcInfo(self.cfg_params)
|
28 |
|
|
endpoint, lfn, SE, SE_PATH, user = stageout.getEndpoint()
|
29 |
|
|
#print endpoint, lfn, SE, SE_PATH, user
|
30 |
|
|
|
31 |
|
|
print "SE:",self.cfg_params['USER.storage_element'],SE," srmPath:",endpoint
|
32 |
|
|
|
33 |
|
|
else:
|
34 |
|
|
print "Local output: ",task['outputDirectory']
|
35 |
|
|
#print task
|
36 |
slacapra |
1.1 |
from ProdCommon.FwkJobRep.ReportParser import readJobReport
|
37 |
|
|
possible_status = [ 'Created',
|
38 |
|
|
'Undefined',
|
39 |
|
|
'Submitting',
|
40 |
|
|
'Submitted',
|
41 |
slacapra |
1.3 |
'NotSubmitted',
|
42 |
slacapra |
1.1 |
'Waiting',
|
43 |
|
|
'Ready',
|
44 |
|
|
'Scheduled',
|
45 |
|
|
'Running',
|
46 |
|
|
'Done',
|
47 |
|
|
'Killing',
|
48 |
|
|
'Killed',
|
49 |
|
|
'Aborted',
|
50 |
|
|
'Unknown',
|
51 |
|
|
'Done (Failed)',
|
52 |
|
|
'Cleared',
|
53 |
spiga |
1.5 |
'Retrieved'
|
54 |
slacapra |
1.1 |
]
|
55 |
|
|
eventsRead=0
|
56 |
slacapra |
1.2 |
eventsRequired=0
|
57 |
slacapra |
1.1 |
filesRead=0
|
58 |
slacapra |
1.2 |
filesRequired=0
|
59 |
slacapra |
1.1 |
for job in task.getJobs():
|
60 |
slacapra |
1.3 |
if (job.runningJob['applicationReturnCode']>0 or job.runningJob['wrapperReturnCode']>0): continue
|
61 |
slacapra |
1.1 |
# get FJR filename
|
62 |
|
|
fjr=task['outputDirectory']+job['outputFiles'][-1]
|
63 |
|
|
#print fjr
|
64 |
|
|
jobReport = readJobReport(fjr)
|
65 |
|
|
if len(jobReport)>0:
|
66 |
|
|
inputFiles=jobReport[0].inputFiles
|
67 |
|
|
for inputFile in inputFiles:
|
68 |
|
|
runs=inputFile.runs
|
69 |
|
|
#print [inputFile[it] for it in ['LFN','EventsRead']]
|
70 |
|
|
# print "FileIn :",inputFile['LFN'],": Events",inputFile['EventsRead']
|
71 |
|
|
# for run in runs.keys():
|
72 |
|
|
# print "Run",run,": lumi sections",runs[run]
|
73 |
|
|
filesRead+=1
|
74 |
|
|
eventsRead+=int(inputFile['EventsRead'])
|
75 |
|
|
|
76 |
|
|
#print jobReport[0].inputFiles,'\n'
|
77 |
|
|
else:
|
78 |
slacapra |
1.3 |
pass
|
79 |
|
|
#print 'no FJR avaialble for job #%s'%job['jobId']
|
80 |
slacapra |
1.1 |
#print "--------------------------"
|
81 |
slacapra |
1.2 |
print "Total Events read: ",eventsRead," required: ",eventsRequired
|
82 |
|
|
print "Total Files read: ",filesRead," required: ",filesRequired
|
83 |
slacapra |
1.1 |
print "Total Jobs : ",len(task.getJobs())
|
84 |
|
|
list_ID={}
|
85 |
|
|
for st in possible_status:
|
86 |
|
|
list_ID = common._db.queryAttrRunJob({'statusScheduler':st},'jobId')
|
87 |
|
|
if (len(list_ID)>0):
|
88 |
|
|
print " # Jobs:",str(st),":",len(list_ID)
|
89 |
|
|
pass
|
90 |
|
|
print "\n----------------------------\n"
|
91 |
|
|
|
92 |
|
|
return
|