1 |
slacapra |
1.1 |
from Actor import *
|
2 |
|
|
import common, crab_util
|
3 |
|
|
import string, os
|
4 |
spiga |
1.9 |
import Statistic
|
5 |
slacapra |
1.1 |
|
6 |
|
|
class Status(Actor):
|
7 |
|
|
def __init__(self, cfg_params, nj_list):
|
8 |
|
|
self.cfg_params = cfg_params
|
9 |
|
|
self.nj_list = nj_list
|
10 |
|
|
self.countDone = 0
|
11 |
|
|
self.countReady = 0
|
12 |
|
|
self.countSched = 0
|
13 |
|
|
self.countRun = 0
|
14 |
|
|
self.countCleared = 0
|
15 |
|
|
self.countToTjob = 0
|
16 |
|
|
|
17 |
spiga |
1.9 |
############################################# daniele
|
18 |
|
|
fileCODE1 = open(common.work_space.logDir()+"/.code","r")
|
19 |
|
|
array = fileCODE1.read().split('::')
|
20 |
|
|
self.ID1 = array[0]
|
21 |
|
|
self.NJC = array[1]
|
22 |
|
|
self.dataset = array[2]
|
23 |
|
|
self.owner = array[3]
|
24 |
|
|
fileCODE1.close()
|
25 |
|
|
#######################################################################################
|
26 |
|
|
|
27 |
|
|
|
28 |
|
|
|
29 |
slacapra |
1.1 |
Status = crab_util.importName('edg_wl_userinterface_common_LbWrapper', 'Status')
|
30 |
|
|
# Bypass edg-job-status interfacing directly to C++ API
|
31 |
|
|
# Job attribute vector to retrieve status without edg-job-status
|
32 |
|
|
self.level = 0
|
33 |
|
|
# Instance of the Status class provided by LB API
|
34 |
|
|
self.jobStat = Status()
|
35 |
|
|
|
36 |
|
|
self.states = [ "Acl", "cancelReason", "cancelling","ce_node","children", \
|
37 |
|
|
"children_hist","children_num","children_states","condorId","condor_jdl", \
|
38 |
|
|
"cpuTime","destination", "done_code","exit_code","expectFrom", \
|
39 |
|
|
"expectUpdate","globusId","jdl","jobId","jobtype", \
|
40 |
|
|
"lastUpdateTime","localId","location", "matched_jdl","network_server", \
|
41 |
slacapra |
1.5 |
"owner","parent_job", "reason","resubmitted","rsl","seed",\
|
42 |
|
|
"stateEnterTime","stateEnterTimes","subjob_failed", \
|
43 |
slacapra |
1.1 |
"user tags" , "status" , "status_code","hierarchy"]
|
44 |
|
|
self.hstates = {}
|
45 |
slacapra |
1.6 |
for key in self.states:
|
46 |
|
|
self.hstates[key]=''
|
47 |
slacapra |
1.1 |
|
48 |
|
|
return
|
49 |
|
|
|
50 |
|
|
def run(self):
|
51 |
|
|
"""
|
52 |
|
|
The main method of the class.
|
53 |
|
|
"""
|
54 |
|
|
common.logger.debug(5, "Status::run() called")
|
55 |
|
|
|
56 |
|
|
common.jobDB.load()
|
57 |
|
|
for nj in self.nj_list:
|
58 |
|
|
st = common.jobDB.status(nj)
|
59 |
|
|
self.countToTjob = self.countToTjob + 1
|
60 |
|
|
jid = common.jobDB.jobId(nj)
|
61 |
|
|
if st == 'S':
|
62 |
slacapra |
1.5 |
result = common.scheduler.queryStatus(jid)
|
63 |
slacapra |
1.11 |
self.processResult_(nj, result, jid)
|
64 |
slacapra |
1.10 |
exit = common.jobDB.exitStatus(nj)
|
65 |
slacapra |
1.4 |
print 'Job %03d:'%(nj+1),jid,result,exit
|
66 |
slacapra |
1.1 |
pass
|
67 |
|
|
else:
|
68 |
slacapra |
1.10 |
exit = common.jobDB.exitStatus(nj)
|
69 |
slacapra |
1.4 |
print 'Job %03d:'%(nj+1),jid,crab_util.crabJobStatusToString(st),exit
|
70 |
slacapra |
1.1 |
pass
|
71 |
|
|
pass
|
72 |
|
|
|
73 |
slacapra |
1.2 |
common.jobDB.save()
|
74 |
|
|
|
75 |
slacapra |
1.1 |
self.Report_()
|
76 |
|
|
pass
|
77 |
|
|
|
78 |
|
|
|
79 |
spiga |
1.9 |
def processResult_(self, nj, result,jid):
|
80 |
|
|
|
81 |
|
|
destination = common.scheduler.queryDest(jid).split(":")[0]
|
82 |
|
|
ID3 = jid.split("/")[3]
|
83 |
|
|
broker = jid.split("/")[2].split(":")[0]
|
84 |
|
|
resFlag = 0
|
85 |
slacapra |
1.3 |
### TODO: set relevant status also to DB
|
86 |
|
|
|
87 |
slacapra |
1.1 |
try:
|
88 |
|
|
if result == 'Done':
|
89 |
|
|
self.countDone = self.countDone + 1
|
90 |
spiga |
1.9 |
exCode = common.scheduler.getExitStatus(jid)
|
91 |
slacapra |
1.3 |
common.jobDB.setStatus(nj, 'D')
|
92 |
slacapra |
1.10 |
jid = common.jobDB.jobId(nj)
|
93 |
|
|
exit = common.scheduler.getExitStatus(jid)
|
94 |
|
|
common.jobDB.setExitStatus(nj, exit)
|
95 |
spiga |
1.9 |
Statistic.notify('checkstatus',resFlag,exCode,self.dataset,self.owner,destination,broker,ID3,self.ID1,self.NJC)
|
96 |
slacapra |
1.1 |
elif result == 'Ready':
|
97 |
|
|
self.countReady = self.countReady + 1
|
98 |
spiga |
1.9 |
Statistic.notify('checkstatus',resFlag,'-----',self.dataset,self.owner,destination,broker,ID3,self.ID1,self.NJC)
|
99 |
slacapra |
1.1 |
elif result == 'Scheduled':
|
100 |
|
|
self.countSched = self.countSched + 1
|
101 |
spiga |
1.9 |
Statistic.notify('checkstatus',resFlag,'-----',self.dataset,self.owner,destination,broker,ID3,self.ID1,self.NJC)
|
102 |
|
|
print 'CAZZOOOOO '+str(destination)
|
103 |
slacapra |
1.1 |
elif result == 'Running':
|
104 |
|
|
self.countRun = self.countRun + 1
|
105 |
spiga |
1.9 |
Statistic.notify('checkstatus',resFlag,'-----',self.dataset,self.owner,destination,broker,ID3,self.ID1,self.NJC)
|
106 |
slacapra |
1.1 |
elif result == 'Aborted':
|
107 |
slacapra |
1.2 |
common.jobDB.setStatus(nj, 'A')
|
108 |
spiga |
1.9 |
Statistic.notify('checkstatus',resFlag,'abort',self.dataset,self.owner,destination,broker,ID3,self.ID1,self.NJC)
|
109 |
slacapra |
1.1 |
pass
|
110 |
|
|
elif result == 'Cancelled':
|
111 |
slacapra |
1.3 |
common.jobDB.setStatus(nj, 'K')
|
112 |
spiga |
1.9 |
Statistic.notify('checkstatus',resFlag,'cancel',self.dataset,self.owner,destination,broker,ID3,self.ID1,self.NJC)
|
113 |
slacapra |
1.1 |
pass
|
114 |
|
|
elif result == 'Cleared':
|
115 |
spiga |
1.9 |
exCode = common.scheduler.getExitStatus(jid)
|
116 |
|
|
Statistic.notify('checkstatus',resFlag,exCode,self.dataset,self.owner,destination,broker,ID3,self.ID1,self.NJC)
|
117 |
slacapra |
1.1 |
self.countCleared = self.countCleared + 1
|
118 |
|
|
except UnboundLocalError:
|
119 |
|
|
common.logger.message('ERROR: UnboundLocalError with ')
|
120 |
|
|
|
121 |
|
|
def Report_(self) :
|
122 |
|
|
|
123 |
|
|
""" Report #jobs for each status """
|
124 |
|
|
|
125 |
|
|
#job_stat = common.job_list.loadStatus()
|
126 |
|
|
|
127 |
|
|
print ''
|
128 |
|
|
print ">>>>>>>>> %i Total Jobs " % (self.countToTjob)
|
129 |
|
|
|
130 |
|
|
if (self.countReady != 0):
|
131 |
|
|
print ''
|
132 |
|
|
print ">>>>>>>>> %i Jobs Ready" % (self.countReady)
|
133 |
|
|
if (self.countSched != 0):
|
134 |
|
|
print ''
|
135 |
|
|
print ">>>>>>>>> %i Jobs Scheduled" % (self.countSched)
|
136 |
|
|
if (self.countRun != 0):
|
137 |
|
|
print ''
|
138 |
|
|
print ">>>>>>>>> %i Jobs Running" % (self.countRun)
|
139 |
|
|
if (self.countCleared != 0):
|
140 |
|
|
print ''
|
141 |
|
|
print ">>>>>>>>> %i Jobs Retrieved (=Cleared)" % (self.countCleared)
|
142 |
|
|
print " You can resubmit them specifying JOB numbers: crab.py -resubmit JOB_number (or range of JOB) -continue"
|
143 |
|
|
print " (i.e -resubmit 1-3 => 1 and 2 and 3 or -resubmit 1,3 => 1 and 3)"
|
144 |
|
|
# if job_stat[6] or job_stat[7]:
|
145 |
|
|
# print ''
|
146 |
|
|
# print ">>>>>>>>> %i Jobs aborted or killed(=cancelled by user)" % (job_stat[6] + job_stat[7])
|
147 |
|
|
# print " Resubmit them with: crab.py -resubmit -continue to resubmit all"
|
148 |
|
|
# print " or specifying JOB numbers (i.e -resubmit 1-3 => 1 and 2 and 3 or -resubmit 1,3 => 1 and 3)"
|
149 |
|
|
# print " "
|
150 |
|
|
if (self.countDone != 0):
|
151 |
|
|
print ">>>>>>>>> %i Jobs Done" % (self.countDone)
|
152 |
|
|
print " Retrieve them with: crab.py -getoutput -continue to retrieve all"
|
153 |
|
|
print " or specifying JOB numbers (i.e -getoutput 1-3 => 1 and 2 and 3 or -getoutput 1,3 => 1 and 3)"
|
154 |
|
|
print('\n')
|
155 |
|
|
pass
|
156 |
|
|
|
157 |
|
|
|