ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/Submitter.py
Revision: 1.19
Committed: Thu Oct 13 17:24:12 2005 UTC (19 years, 6 months ago) by slacapra
Content type: text/x-python
Branch: MAIN
CVS Tags: CRAB_1_0_0_beta4
Changes since 1.18: +1 -1 lines
Log Message:
cosmetic

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