ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/Submitter.py
Revision: 1.23
Committed: Wed Oct 19 16:12:27 2005 UTC (19 years, 6 months ago) by slacapra
Content type: text/x-python
Branch: MAIN
Changes since 1.22: +4 -1 lines
Log Message:
try also notify...

File Contents

# User Rev Content
1 nsmirnov 1.1 from Actor import *
2 nsmirnov 1.6 from crab_util import *
3 nsmirnov 1.2 import common
4 corvo 1.9 from ApmonIf import ApmonIf
5 spiga 1.10 import Statistic
6 nsmirnov 1.1
7     class Submitter(Actor):
8 nsmirnov 1.4 def __init__(self, cfg_params, nj_list):
9 nsmirnov 1.1 self.cfg_params = cfg_params
10 nsmirnov 1.4 self.nj_list = nj_list
11 spiga 1.10 #############################################
12 slacapra 1.18 ### this is a common block!
13 spiga 1.10 fileCODE1 = open(common.work_space.logDir()+"/.code","r")
14     array = fileCODE1.read().split('::')
15     self.ID1 = array[0]
16     self.NJC = array[1]
17     self.dataset = array[2]
18     self.owner = array[3]
19     fileCODE1.close()
20 corvo 1.21 self.mon = ApmonIf()
21 spiga 1.10
22 nsmirnov 1.1 return
23    
24     def run(self):
25 nsmirnov 1.2 """
26     The main method of the class.
27     """
28     common.logger.debug(5, "Submitter::run() called")
29 slacapra 1.18 # SL what the hell is Apmon doing here????
30 slacapra 1.7 firstJob=self.nj_list[0]
31     match = common.scheduler.listMatch(firstJob)
32 slacapra 1.8 if match:
33     common.logger.message("Found compatible resources "+str(match))
34     else:
35     raise CrabException("No compatible resources found!")
36 fanzago 1.16 #########
37 nsmirnov 1.2 # Loop over jobs
38 nsmirnov 1.6 njs = 0
39 corvo 1.15 try:
40 corvo 1.17 for nj in self.nj_list:
41     st = common.jobDB.status(nj)
42 corvo 1.21 # print "nj = ", nj
43     # print "st = ", st
44 corvo 1.17 if st != 'C' and st != 'K' and st != 'A' and st != 'RC':
45     long_st = crabJobStatusToString(st)
46 slacapra 1.19 msg = "Job # %d not submitted: status %s"%(nj+1, long_st)
47 slacapra 1.18 common.logger.message(msg)
48 corvo 1.17 continue
49    
50     common.logger.message("Submitting job # "+`(nj+1)`)
51     jid = common.scheduler.submit(nj)
52    
53     common.jobDB.setStatus(nj, 'S')
54     common.jobDB.setJobId(nj, jid)
55     njs += 1
56    
57     ############################################
58    
59     destination = common.scheduler.queryDest(jid).split(":")[0]
60     ID3 = jid.split("/")[3]
61     broker = jid.split("/")[2].split(":")[0]
62     if st == 'C':
63     resFlag = 0
64     elif st == 'RC':
65     resFlag = 2
66     else:
67     resFlag = 0
68     pass
69    
70 slacapra 1.23 try:
71     Statistic.notify('submit',resFlag,'-----',self.dataset,self.owner,destination,broker,ID3,self.ID1,self.NJC)
72     except:
73     pass
74 corvo 1.17
75     try:
76 slacapra 1.22 # SL this is crap! Should not be here!!!!
77     # List of parameters to be sent to ML monitor system
78     user = os.getlogin()
79     taskId = os.getlogin()+'_'+string.split(common.work_space.topDir(),'/')[-2]
80     jobId = str(nj)
81     sid = jid
82     try:
83     application = os.path.basename(os.environ['SCRAMRT_LOCALRT'])
84     except KeyError:
85     application = os.path.basename(os.environ['LOCALRT'])
86 corvo 1.17
87 slacapra 1.22 nevtJob = common.jobDB.maxEvents(nj)
88     exe = self.cfg_params['USER.executable']
89     tool = common.prog_name
90     scheduler = self.cfg_params['CRAB.scheduler']
91     taskType = 'analysis'
92     vo = 'cms'
93     rb = sid.split(':')[1]
94     rb = rb.replace('//', '')
95     params = {'taskId': taskId, 'jobId': jobId, 'sid': sid, 'application': application, \
96     'exe': exe, 'nevtJob': nevtJob, 'tool': tool, 'scheduler': scheduler, \
97     'user': user, 'taskType': taskType, 'vo': vo, 'dataset': self.dataset, 'owner': self.owner, 'broker': rb}
98     self.mon.fillDict(params)
99     self.mon.sendToML()
100     except:
101     pass
102 corvo 1.17 except:
103 slacapra 1.22 common.logger.message("Submitter::run Exception raised")
104 corvo 1.17 common.jobDB.save()
105 slacapra 1.18
106 corvo 1.17 common.jobDB.save()
107 corvo 1.15
108 nsmirnov 1.6 msg = '\nTotal of %d jobs submitted'%njs
109     if njs != len(self.nj_list) :
110     msg += ' (from %d requested).'%(len(self.nj_list))
111     pass
112     else:
113     msg += '.'
114     pass
115 nsmirnov 1.2 common.logger.message(msg)
116 nsmirnov 1.1 return
117