2 |
|
from SchedulerLocal import SchedulerLocal |
3 |
|
from crab_exceptions import * |
4 |
|
from crab_util import * |
5 |
– |
from crab_logger import Logger |
5 |
|
import common |
6 |
|
from LFNBaseName import * |
7 |
|
|
17 |
|
|
18 |
|
def __init__(self): |
19 |
|
Scheduler.__init__(self,"LSF") |
20 |
< |
|
20 |
> |
self.OSBsize = None |
21 |
> |
|
22 |
|
return |
23 |
|
|
24 |
|
def configure(self, cfg_params): |
25 |
|
SchedulerLocal.configure(self, cfg_params) |
26 |
|
self.outputDir = cfg_params.get('USER.outputdir' ,common.work_space.resDir()) |
27 |
< |
self.environment_unique_identifier = "https://"+common.scheduler.name()+":/${LSB_BATCH_JID}-"+ \ |
28 |
< |
string.replace(common._db.queryTask('name'),"_","-") |
27 |
> |
self.res = cfg_params.get(self.name().upper()+'.resource','"type==SLC5_64 || type==SLC4_64"') |
28 |
|
|
29 |
+ |
self.pool = cfg_params.get('USER.storage_pool',None) |
30 |
|
return |
31 |
|
|
32 |
+ |
def envUniqueID(self): |
33 |
+ |
id = "https://"+common.scheduler.name().upper()+":/${LSB_BATCH_JID}-"+ \ |
34 |
+ |
string.replace(common._db.queryTask('name'),"_","-") |
35 |
+ |
return id |
36 |
+ |
|
37 |
|
def realSchedParams(self,cfg_params): |
38 |
|
""" |
39 |
< |
Return dictionary with specific parameters, to use |
40 |
< |
with real scheduler |
39 |
> |
Return dictionary with specific parameters, to use |
40 |
> |
with real scheduler |
41 |
|
""" |
42 |
< |
### use by the BossLite script |
42 |
> |
### use by the BossLite script |
43 |
|
self.cpCmd = cfg_params.get(self.name().upper()+'.cp_command','cp') |
44 |
|
self.rfioName = cfg_params.get(self.name().upper()+'.rfio_server','') |
45 |
|
|
46 |
|
params = { 'cpCmd' : self.cpCmd, \ |
47 |
< |
'rfipName' : self.rfioName |
47 |
> |
'rfioName' : self.rfioName |
48 |
|
} |
49 |
|
return params |
50 |
|
|
51 |
+ |
def wsSetupEnvironment(self): |
52 |
+ |
""" |
53 |
+ |
Returns part of a job script which does scheduler-specific work. |
54 |
+ |
""" |
55 |
+ |
txt = SchedulerLocal.wsSetupEnvironment(self) |
56 |
+ |
#this is needed to support slc4->slc5 migration |
57 |
+ |
txt += 'export RFIO_PORT=5001\n' |
58 |
+ |
txt += '\n' |
59 |
+ |
return txt |
60 |
|
def sched_parameter(self,i,task): |
61 |
|
""" |
62 |
|
Returns parameter scheduler-specific, to use with BOSS . |
65 |
|
|
66 |
|
if (self.queue): |
67 |
|
sched_param += '-q '+self.queue +' ' |
68 |
< |
if (self.res): sched_param += ' -R '+self.res +' ' |
69 |
< |
|
56 |
< |
sched_param+='-cwd '+ str(self.outputDir) + ' ' |
68 |
> |
if (self.res): sched_param += ' -R '+self.res +' ' |
69 |
> |
# sched_param+='-cwd '+ str(self.outputDir) + ' ' |
70 |
|
return sched_param |
71 |
|
|
72 |
< |
def loggingInfo(self, id): |
72 |
> |
def listMatch(self, dest, full): |
73 |
> |
""" |
74 |
> |
""" |
75 |
> |
if len(dest)!=0: |
76 |
> |
sites = [self.blackWhiteListParser.cleanForBlackWhiteList(dest,'list')] |
77 |
> |
else: |
78 |
> |
sites = [str(getLocalDomain(self))] |
79 |
> |
return sites |
80 |
> |
|
81 |
> |
def loggingInfo(self, id, fname): |
82 |
|
""" return logging info about job nj """ |
83 |
< |
cmd = 'bjobs -l ' + id |
83 |
> |
lsfid = common._db.queryRunJob('schedulerId',id) |
84 |
> |
cmd = 'bjobs -l ' + str(lsfid[0]) |
85 |
|
cmd_out = runCommand(cmd) |
86 |
< |
return cmd_out |
86 |
> |
f = open(fname,'w') |
87 |
> |
f.write(cmd_out) |
88 |
> |
f.close() |
89 |
> |
return fname |
90 |
> |
|
91 |
> |
def wsCopyOutput(self): |
92 |
> |
txt=self.wsCopyOutput_comm(self.pool) |
93 |
> |
return txt |
94 |
|
|
95 |
|
def wsExitFunc(self): |
96 |
|
""" |
102 |
|
txt += '#\n\n' |
103 |
|
|
104 |
|
txt += 'func_exit() { \n' |
105 |
< |
txt += self.wsExitFunc_common() |
105 |
> |
txt += SchedulerLocal.wsExitFunc_common(self) |
106 |
|
|
107 |
|
txt += ' cp *.${LSB_BATCH_JID}.out CMSSW_${NJob}.stdout \n' |
108 |
|
txt += ' cp *.${LSB_BATCH_JID}.err CMSSW_${NJob}.stderr \n' |
111 |
|
txt += '}\n' |
112 |
|
|
113 |
|
return txt |
84 |
– |
|
85 |
– |
def wsCopyOutput_tmp(self,pool=None): |
86 |
– |
######################################################################### |
87 |
– |
### Temporary we added this function to be used by |
88 |
– |
### SchedulerLsf and SchedulerCaf to have a copy function based on cmscp |
89 |
– |
### This function overwrite the wsCopyOutput written in SchedulerLocal |
90 |
– |
### and used by CondorLocal |
91 |
– |
######################################################################### |
92 |
– |
""" |
93 |
– |
Write a CopyResults part of a job script, e.g. |
94 |
– |
to copy produced output into a storage element. |
95 |
– |
""" |
96 |
– |
txt = '\n' |
97 |
– |
if not self.copy_data: return txt |
98 |
– |
|
99 |
– |
if int(self.publish_data) == 1: |
100 |
– |
self.path_add = PFNportion(self.publish_data_name,LocalUser=True) +'_${PSETHASH}/' |
101 |
– |
self.SE_path = self.SE_path + self.path_add |
102 |
– |
|
103 |
– |
txt += '#\n' |
104 |
– |
txt += '# COPY OUTPUT FILE TO '+self.SE_path+ '\n' |
105 |
– |
txt += '#\n\n' |
106 |
– |
|
107 |
– |
if (pool): |
108 |
– |
txt += 'export STAGE_SVCCLASS='+str(pool)+'\n' |
109 |
– |
|
110 |
– |
if int(self.publish_data) == 1: |
111 |
– |
txt += 'export SE='+self.SE+'\n' |
112 |
– |
|
113 |
– |
txt += 'export SE_PATH='+self.SE_path+'\n' |
114 |
– |
|
115 |
– |
txt += 'export TIME_STAGEOUT_INI=`date +%s` \n' |
116 |
– |
txt += '# Verify is the SE path exists '+self.SE_path+'\n' |
117 |
– |
txt += '#\n\n' |
118 |
– |
txt += 'verifySePath ' + self.SE_path + '\n' |
119 |
– |
txt += 'if [ $exit_verifySePath -ne 0 ]; then\n' |
120 |
– |
txt += ' echo "Problem with the SE path $SE_PATH"\n' |
121 |
– |
txt += ' SE=""\n' |
122 |
– |
txt += ' SE_PATH=""\n' |
123 |
– |
txt += ' job_exit_code=$exit_verifySePath\n' |
124 |
– |
txt += 'else\n' |
125 |
– |
txt += ' echo ">>> Copy output files from WN = `hostname` to SE_PATH = $SE_PATH :"\n' |
126 |
– |
txt += ' copy_exit_status=0\n' |
127 |
– |
txt += ' for out_file in $file_list ; do\n' |
128 |
– |
txt += ' if [ -e $SOFTWARE_DIR/$out_file ] ; then\n' |
129 |
– |
txt += ' echo "Trying to copy output file to $SE_PATH"\n' |
130 |
– |
txt += ' cmscp $middleware $SOFTWARE_DIR/$out_file $out_file ${SE_PATH}\n' |
131 |
– |
txt += ' if [ $cmscp_exit_status -ne 0 ]; then\n' |
132 |
– |
txt += ' echo "Problem copying $out_file to $SE_PATH"\n' |
133 |
– |
txt += ' copy_exit_status=$cmscp_exit_status\n' |
134 |
– |
txt += ' else\n' |
135 |
– |
txt += ' echo "output copied into $SE/$SE_PATH directory"\n' |
136 |
– |
txt += ' fi\n' |
137 |
– |
txt += ' else\n' |
138 |
– |
txt += ' copy_exit_status=60302\n' |
139 |
– |
txt += ' echo "StageOutExitStatus = $copy_exit_status" | tee -a $RUNTIME_AREA/$repo\n' |
140 |
– |
txt += ' echo "StageOutExitStatusReason = file to copy not found" | tee -a $RUNTIME_AREA/$repo\n' |
141 |
– |
txt += ' fi\n' |
142 |
– |
txt += ' done\n' |
143 |
– |
txt += ' if [ $copy_exit_status -ne 0 ]; then\n' |
144 |
– |
txt += ' SE=""\n' |
145 |
– |
txt += ' SE_PATH=""\n' |
146 |
– |
txt += ' job_exit_code=$copy_exit_status\n' |
147 |
– |
txt += ' fi\n' |
148 |
– |
txt += 'export TIME_STAGEOUT_END=`date +%s` \n' |
149 |
– |
txt += 'let "TIME_STAGEOUT = TIME_STAGEOUT_END - TIME_STAGEOUT_INI" \n' |
150 |
– |
txt += 'fi\n' |
151 |
– |
|
152 |
– |
return txt |
153 |
– |
|
154 |
– |
def wsCopyOutput(self): |
155 |
– |
pool=None |
156 |
– |
txt=self.wsCopyOutput_tmp(pool) |
157 |
– |
return txt |