1 |
from Scheduler import Scheduler
|
2 |
from SchedulerLsf import SchedulerLsf
|
3 |
from crab_exceptions import *
|
4 |
import common
|
5 |
|
6 |
import os,string
|
7 |
|
8 |
#
|
9 |
# Naming convention:
|
10 |
# methods starting with 'ws' are responsible to provide
|
11 |
# corresponding part of the job script ('ws' stands for 'write script').
|
12 |
#
|
13 |
|
14 |
class SchedulerCaf(SchedulerLsf) :
|
15 |
|
16 |
def __init__(self):
|
17 |
SchedulerLsf.__init__(self)
|
18 |
Scheduler.__init__(self,"CAF")
|
19 |
self.OSBsize = 55*1000*1000 # 55 MB
|
20 |
|
21 |
return
|
22 |
|
23 |
def configure(self, cfg_params):
|
24 |
"""
|
25 |
CAF is just a special queue and resources for LSF at CERN
|
26 |
"""
|
27 |
SchedulerLsf.configure(self, cfg_params)
|
28 |
self.queue = cfg_params.get(self.name().upper()+'.queue','cmscaf1nw')
|
29 |
self.res = cfg_params.get(self.name().upper()+'.resource','"type==SLC5_64 || type==SLC4_64"')
|
30 |
self.group = cfg_params.get(self.name().upper()+'.group', None)
|
31 |
|
32 |
def sched_parameter(self,i,task):
|
33 |
"""
|
34 |
Returns parameter scheduler-specific, to use with BOSS .
|
35 |
"""
|
36 |
sched_param= ''
|
37 |
|
38 |
if (self.queue):
|
39 |
sched_param += '-q '+self.queue +' '
|
40 |
if (self.res): sched_param += ' -R '+self.res +' '
|
41 |
if (self.group): sched_param += ' -G '+str(self.group).upper() +' '
|
42 |
return sched_param
|
43 |
|
44 |
def wsSetupEnvironment(self):
|
45 |
#Returns part of a job script which does scheduler-specific work.
|
46 |
txt = SchedulerLsf.wsSetupEnvironment(self)
|
47 |
txt += '# CAF specific stuff\n'
|
48 |
txt += 'echo "----- ENV CAF BEFORE sourcing /afs/cern.ch/cms/caf/setup.sh -----"\n'
|
49 |
txt += 'echo "CMS_PATH = $CMS_PATH"\n'
|
50 |
txt += 'echo "STAGE_SVCCLASS = $STAGE_SVCCLASS"\n'
|
51 |
txt += 'echo "STAGER_TRACE = $STAGER_TRACE"\n'
|
52 |
txt += 'source /afs/cern.ch/cms/caf/setup.sh \n'
|
53 |
txt += '\n'
|
54 |
txt += 'echo "----- ENV CAF AFTER sourcing /afs/cern.ch/cms/caf/setup.sh -----"\n'
|
55 |
txt += 'echo "CMS_PATH = $CMS_PATH"\n'
|
56 |
txt += 'echo "STAGE_SVCCLASS = $STAGE_SVCCLASS"\n'
|
57 |
txt += 'echo "STAGER_TRACE = $STAGER_TRACE"\n'
|
58 |
txt += '\n'
|
59 |
return txt
|
60 |
|
61 |
def wsExitFunc(self):
|
62 |
"""
|
63 |
"""
|
64 |
txt = '\n'
|
65 |
|
66 |
txt += '#\n'
|
67 |
txt += '# EXECUTE THIS FUNCTION BEFORE EXIT \n'
|
68 |
txt += '#\n\n'
|
69 |
txt += 'func_exit() { \n'
|
70 |
txt += self.wsExitFunc_common()
|
71 |
|
72 |
txt += ' cp *.${LSB_BATCH_JID}.out CMSSW_${NJob}.stdout \n'
|
73 |
txt += ' cp *.${LSB_BATCH_JID}.err CMSSW_${NJob}.stderr \n'
|
74 |
txt += ' exit $job_exit_code\n'
|
75 |
txt += '}\n'
|
76 |
return txt
|