ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/Resubmitter.py
Revision: 1.6
Committed: Tue May 6 21:32:02 2008 UTC (16 years, 11 months ago) by ewv
Content type: text/x-python
Branch: MAIN
Changes since 1.5: +7 -7 lines
Log Message:
Update allowed status for kill, fix bug in Resubmitter

File Contents

# User Rev Content
1 slacapra 1.1 from Submitter import Submitter
2     import common
3     from crab_util import *
4 spiga 1.4 from crab_exceptions import *
5 slacapra 1.1
6     class Resubmitter(Submitter):
7 spiga 1.3 def __init__(self, cfg_params, jobs):
8     self.cfg_params = cfg_params
9    
10 slacapra 1.1 nj_list = []
11 ewv 1.6
12 spiga 1.3 nj_list = self.checkAlowedJob(jobs,nj_list)
13 ewv 1.6
14     self.manageNewRunJobs(nj_list)
15    
16 spiga 1.3 common.logger.message('Jobs '+str(nj_list)+' will be resubmitted')
17     Submitter.__init__(self, cfg_params, nj_list, 'range')
18 ewv 1.6
19 spiga 1.3 return
20 slacapra 1.1
21 spiga 1.3 def checkAlowedJob(self,jobs,nj_list):
22     listRunField=[]
23     run_jobToSave = {'status' :'C', \
24 spiga 1.5 'statusScheduler' : 'Created'}
25 slacapra 1.1
26 spiga 1.3 task=common._db.getTask(jobs)
27     for job in task.jobs:
28     st = job.runningJob['status']
29     nj = job['id']
30     if st in ['K','A','SE','E']:
31     nj_list.append(int(nj))
32     listRunField.append(run_jobToSave)
33     elif st == 'C':
34     common.logger.message('Job #'+`int(nj)`+' has status '+str(job.runningJob['statusScheduler'])+' not yet submitted!!!')
35     elif st in ['SD','D']:
36     common.logger.message('Job #'+`int(nj)`+' has status '+str(job.runningJob['statusScheduler'])+' must be retrieved before resubmission')
37     else:
38     common.logger.message('Job #'+`nj`+' has status '+str(job.runningJob['statusScheduler'])+' must be "killed" before resubmission')
39 spiga 1.4
40     if len(nj_list) == 0 :
41 spiga 1.3 msg='No jobs to resubmit'
42     raise CrabException(msg)
43 spiga 1.4 else:
44 ewv 1.6 common._db.updateRunJob_(nj_list, listRunField )
45 spiga 1.3 return nj_list
46 ewv 1.6
47 spiga 1.3 if UseServer==1: SubmitterServer.__init__(self, cfg_params, nj_list, 'range')
48 spiga 1.5
49     def manageNewRunJobs(self,nj_list):
50     """
51     Get new running instances
52     """
53     common._db.newRunJobs(nj_list)
54     return