ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/Reporter.py
Revision: 1.4
Committed: Tue May 26 10:23:01 2009 UTC (15 years, 11 months ago) by spiga
Content type: text/x-python
Branch: MAIN
CVS Tags: CRAB_2_6_0_pre4, CRAB_2_6_0_pre3
Changes since 1.3: +1 -1 lines
Log Message:
adapting code to logging usage. (crab_logger removed)

File Contents

# Content
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( "Reporter::run() called")
19 task = common._db.getTask()
20 #print self.cfg_params
21 print "\n----------------------------\n"
22 print "Dataset: ",task['dataset']
23 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 from ProdCommon.FwkJobRep.ReportParser import readJobReport
37 possible_status = [ 'Created',
38 'Undefined',
39 'Submitting',
40 'Submitted',
41 'NotSubmitted',
42 'Waiting',
43 'Ready',
44 'Scheduled',
45 'Running',
46 'Done',
47 'Killing',
48 'Killed',
49 'Aborted',
50 'Unknown',
51 'Done (Failed)',
52 'Cleared',
53 'retrieved'
54 ]
55 eventsRead=0
56 eventsRequired=0
57 filesRead=0
58 filesRequired=0
59 for job in task.getJobs():
60 if (job.runningJob['applicationReturnCode']>0 or job.runningJob['wrapperReturnCode']>0): continue
61 # 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 pass
79 #print 'no FJR avaialble for job #%s'%job['jobId']
80 #print "--------------------------"
81 print "Total Events read: ",eventsRead," required: ",eventsRequired
82 print "Total Files read: ",filesRead," required: ",filesRequired
83 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