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