ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/Resubmitter.py
Revision: 1.1
Committed: Wed Feb 13 18:17:53 2008 UTC (17 years, 2 months ago) by slacapra
Content type: text/x-python
Branch: MAIN
CVS Tags: CRAB_2_1_2, CRAB_2_1_2_pre2, CRAB_2_1_2_pre1, CRAB_2_1_1, CRAB_2_1_1_pre3, CRAB_2_2_0_pre1, CRAB_2_1_1_pre1, CRAB_2_1_0, CRAB_2_1_0_pre6, CRAB_2_1_0_pre5
Branch point for: CRAB_2_1_2_br, CRAB_2_1_1_pre2
Log Message:
Fix problem in resubmission when passing a parameter the number of the job you want to resubmit
eg -resubmit 4
now means (as was before) to resubmit job #4, not to resubmit 4 jobs.
Create a new class Resubmitter (derived from Submitter) to deal with the logic of selecting the job to be resubmitetd from the user request and job status. This clean up a bit crab.py
The actual submission is always done by Submitter::run()

File Contents

# User Rev Content
1 slacapra 1.1 from Submitter import Submitter
2     import common
3     from crab_util import *
4    
5     class Resubmitter(Submitter):
6     def __init__(self, cfg_params, jobs, UseServer=0):
7     nj_list = []
8     for nj in jobs:
9     st = common.jobDB.status(int(nj)-1)
10     if st in ['K','A']:
11     nj_list.append(int(nj)-1)
12     common.jobDB.setStatus(int(nj)-1,'C')
13     elif st == 'Y':
14     common.scheduler.moveOutput(nj)
15     nj_list.append(int(nj)-1)
16     st = common.jobDB.setStatus(int(nj)-1,'RC')
17     elif st in ['C','X']:
18     common.logger.message('Job #'+`int(nj)`+' has status '+crabJobStatusToString(st)+' not yet submitted!!!')
19     pass
20     elif st == 'D':
21     common.logger.message('Job #'+`int(nj)`+' has status '+crabJobStatusToString(st)+' must be retrieved before resubmission')
22     else:
23     common.logger.message('Job #'+`nj`+' has status '+crabJobStatusToString(st)+' must be "killed" before resubmission')
24     pass
25    
26    
27     if len(nj_list) != 0:
28     nj_list.sort()
29    
30     # remove job ids from the submission history file (for the server) # Fabio
31     if (UseServer == 1):
32     file = open(common.work_space.shareDir()+'/submit_directive','r')
33     prev_subms = str(file.readlines()[0]).split('\n')[0]
34     file.close()
35    
36     new_subms = []
37     if prev_subms != 'all':
38     # remove the jobs in nj_list from the history
39     new_subms = [ j for j in eval(prev_subms) not in nj_list ]
40    
41     file = open(common.work_space.shareDir()+'/submit_directive','w')
42     file.write(str(new_subms))
43     file.close()
44     pass
45     pass
46     Submitter.__init__(self, cfg_params, nj_list, 'range')
47     pass