ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/Resubmitter.py
Revision: 1.14
Committed: Wed Jun 10 11:40:52 2009 UTC (15 years, 10 months ago) by slacapra
Content type: text/x-python
Branch: MAIN
CVS Tags: CRAB_2_6_0_pre9, CRAB_2_6_0_pre8
Changes since 1.13: +18 -19 lines
Log Message:
mods to use new filed "state" to check if action is allowed

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 slacapra 1.14 nj_list = self.checkAllowedJob(jobs,nj_list)
13 ewv 1.6
14 spiga 1.12 common.logger.info('Jobs '+str(nj_list)+' will be resubmitted')
15 spiga 1.3 Submitter.__init__(self, cfg_params, nj_list, 'range')
16 ewv 1.6
17 spiga 1.3 return
18 slacapra 1.1
19 slacapra 1.14 def checkAllowedJob(self,jobs,nj_list):
20 spiga 1.3 listRunField=[]
21 slacapra 1.1
22 spiga 1.3 task=common._db.getTask(jobs)
23     for job in task.jobs:
24 slacapra 1.14 st = job.runningJob['state']
25     nj = int(job['jobId'])
26     if st in ['KillSuccess','SubFailed','Cleared','Aborted']:
27     #['K','A','SE','E','DA','NS']:
28     nj_list.append(nj)
29     elif st == 'Created':
30     common.logger.info('Job #'+`nj`+' last action was '+str(job.runningJob['state'])+' not yet submitted: use -submit')
31     elif st in ['Terminated']:
32     common.logger.info('Job #'+`nj`+' last action was '+str(job.runningJob['state'])+' must be retrieved (-get) before resubmission')
33 spiga 1.3 else:
34 slacapra 1.14 common.logger.info('Job #'+`nj`+' last action was '+str(job.runningJob['state'])+' actual status is '\
35     +str(job.runningJob['statusScheduler'])+' must be killed (-kill) before resubmission')
36     if (job.runningJob['state']=='KillRequest'): common.logger.info('\t\tthe previous Kill request is being processed')
37    
38 spiga 1.4
39     if len(nj_list) == 0 :
40 spiga 1.3 msg='No jobs to resubmit'
41     raise CrabException(msg)
42 spiga 1.5
43 slacapra 1.14 # Get new running instances
44 spiga 1.5 common._db.newRunJobs(nj_list)
45 slacapra 1.14
46     return nj_list