1 |
|
from Scheduler import Scheduler |
2 |
|
from SchedulerLsf import SchedulerLsf |
3 |
|
from crab_exceptions import * |
4 |
– |
from crab_logger import Logger |
4 |
|
import common |
5 |
|
|
6 |
|
import os,string |
16 |
|
def __init__(self): |
17 |
|
SchedulerLsf.__init__(self) |
18 |
|
Scheduler.__init__(self,"CAF") |
19 |
+ |
self.OSBsize = 55000000 |
20 |
|
|
21 |
|
return |
22 |
|
|
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','cmscaf') |
29 |
< |
self.res = cfg_params.get(self.name().upper()+'.resource','cmscaf') |
30 |
< |
self.pool = cfg_params.get('USER.storage_pool','cmscafuser') |
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 wsSetupEnvironment(self): |
32 |
> |
def sched_parameter(self,i,task): |
33 |
|
""" |
34 |
< |
Returns part of a job script which does scheduler-specific work. |
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 += 'export STAGE_SVCCLASS=cmscaf \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 wsCopyOutput(self): |
62 |
< |
### default is the name of the storage pool |
63 |
< |
### where users can copy job outputs |
64 |
< |
txt=self.wsCopyOutput_comm(self.pool) |
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 += ' tar zcvf ${out_files}.tgz ${filesToCheck}\n' |
75 |
> |
txt += ' tmp_size=`ls -gGrta ${out_files}.tgz | awk \'{ print $3 }\'`\n' |
76 |
> |
txt += ' rm ${out_files}.tgz\n' |
77 |
> |
txt += ' size=`expr $tmp_size`\n' |
78 |
> |
txt += ' echo "Total Output dimension: $size"\n' |
79 |
> |
txt += ' limit='+str(self.OSBsize) +' \n' |
80 |
> |
txt += ' echo "WARNING: output files size limit is set to: $limit"\n' |
81 |
> |
txt += ' if [ "$limit" -lt "$size" ]; then\n' |
82 |
> |
txt += ' exceed=1\n' |
83 |
> |
txt += ' job_exit_code=70000\n' |
84 |
> |
txt += ' echo "Output Sanbox too big. Produced output is lost "\n' |
85 |
> |
txt += ' else\n' |
86 |
> |
txt += ' exceed=0\n' |
87 |
> |
txt += ' echo "Total Output dimension $size is fine."\n' |
88 |
> |
txt += ' fi\n' |
89 |
> |
|
90 |
> |
txt += ' echo "JOB_EXIT_STATUS = $job_exit_code"\n' |
91 |
> |
txt += ' echo "JobExitCode=$job_exit_code" >> $RUNTIME_AREA/$repo\n' |
92 |
> |
txt += ' dumpStatus $RUNTIME_AREA/$repo\n' |
93 |
> |
txt += ' if [ $exceed -ne 1 ]; then\n' |
94 |
> |
txt += ' tar zcvf ${out_files}.tgz ${final_list}\n' |
95 |
> |
txt += ' else\n' |
96 |
> |
txt += ' tar zcvf ${out_files}.tgz CMSSW_${NJob}.stdout CMSSW_${NJob}.stderr\n' |
97 |
> |
txt += ' fi\n' |
98 |
> |
txt += ' python $RUNTIME_AREA/fillCrabFjr.py $RUNTIME_AREA/crab_fjr_$NJob.xml --errorcode $job_exit_code \n' |
99 |
> |
txt += ' exit $job_exit_code\n' |
100 |
> |
txt += '}\n' |
101 |
|
return txt |