4 |
|
from crab_util import * |
5 |
|
import common |
6 |
|
|
7 |
< |
import os, sys, tempfile |
7 |
> |
import os, sys, time |
8 |
|
|
9 |
|
class SchedulerEdg(Scheduler): |
10 |
|
def __init__(self): |
11 |
|
Scheduler.__init__(self,"EDG") |
12 |
+ |
self.states = [ "Acl", "cancelReason", "cancelling","ce_node","children", \ |
13 |
+ |
"children_hist","children_num","children_states","condorId","condor_jdl", \ |
14 |
+ |
"cpuTime","destination", "done_code","exit_code","expectFrom", \ |
15 |
+ |
"expectUpdate","globusId","jdl","jobId","jobtype", \ |
16 |
+ |
"lastUpdateTime","localId","location", "matched_jdl","network_server", \ |
17 |
+ |
"owner","parent_job", "reason","resubmitted","rsl","seed",\ |
18 |
+ |
"stateEnterTime","stateEnterTimes","subjob_failed", \ |
19 |
+ |
"user tags" , "status" , "status_code","hierarchy"] |
20 |
|
return |
21 |
|
|
22 |
|
def configure(self, cfg_params): |
23 |
|
|
16 |
– |
try: self.edg_ui_cfg = cfg_params["EDG.rb_config"] |
17 |
– |
except KeyError: self.edg_ui_cfg = '' |
18 |
– |
|
24 |
|
try: self.edg_config = cfg_params["EDG.config"] |
25 |
|
except KeyError: self.edg_config = '' |
26 |
|
|
36 |
|
try: self.EDG_retry_count = cfg_params['EDG.retry_count'] |
37 |
|
except KeyError: self.EDG_retry_count = '' |
38 |
|
|
39 |
< |
try: |
40 |
< |
self.VO = cfg_params['EDG.virtual_organization'] |
36 |
< |
except KeyError: |
37 |
< |
msg = 'EDG.virtual_organization is mandatory.' |
38 |
< |
raise CrabException(msg) |
39 |
> |
try: self.VO = cfg_params['EDG.virtual_organization'] |
40 |
> |
except KeyError: self.VO = 'cms' |
41 |
|
|
42 |
< |
|
43 |
< |
#self.scripts_dir = common.bin_dir + '/scripts' |
44 |
< |
#self.cmd_prefix = 'edg' |
45 |
< |
#if common.LCG_version == '0' : self.cmd_prefix = 'dg' |
42 |
> |
try: self.return_data = cfg_params['USER.return_data'] |
43 |
> |
except KeyError: self.return_data = 1 |
44 |
> |
|
45 |
> |
try: |
46 |
> |
self.copy_data = cfg_params["USER.copy_data"] |
47 |
> |
if int(self.copy_data) == 1: |
48 |
> |
try: |
49 |
> |
self.SE = cfg_params['USER.storage_element'] |
50 |
> |
self.SE_PATH = cfg_params['USER.storage_path'] |
51 |
> |
except KeyError: |
52 |
> |
msg = "Error. The [USER] section does not have 'storage_element'" |
53 |
> |
msg = msg + " and/or 'storage_path' entries, necessary to copy the output" |
54 |
> |
common.logger.message(msg) |
55 |
> |
raise CrabException(msg) |
56 |
> |
except KeyError: self.copy_data = 0 |
57 |
> |
|
58 |
> |
if ( int(self.return_data) == 0 and int(self.copy_data) == 0 ): |
59 |
> |
msg = 'Warning: return_data = 0 and copy_data = 0 ==> your exe output will be lost\n' |
60 |
> |
msg = msg + 'Please modify return_data and copy_data value in your crab.cfg file\n' |
61 |
> |
raise CrabException(msg) |
62 |
> |
|
63 |
> |
try: |
64 |
> |
self.register_data = cfg_params["USER.register_data"] |
65 |
> |
if int(self.register_data) == 1: |
66 |
> |
try: |
67 |
> |
self.LFN = cfg_params['USER.lfn_dir'] |
68 |
> |
except KeyError: |
69 |
> |
msg = "Error. The [USER] section does not have 'lfn_dir' value" |
70 |
> |
msg = msg + " it's necessary for RLS registration" |
71 |
> |
common.logger.message(msg) |
72 |
> |
raise CrabException(msg) |
73 |
> |
except KeyError: self.register_data = 0 |
74 |
> |
|
75 |
> |
if ( int(self.copy_data) == 0 and int(self.register_data) == 1 ): |
76 |
> |
msg = 'Warning: register_data = 1 must be used with copy_data = 1\n' |
77 |
> |
msg = msg + 'Please modify copy_data value in your crab.cfg file\n' |
78 |
> |
common.logger.message(msg) |
79 |
> |
raise CrabException(msg) |
80 |
> |
|
81 |
> |
try: self.EDG_requirements = cfg_params['EDG.requirements'] |
82 |
> |
except KeyError: self.EDG_requirements = '' |
83 |
> |
|
84 |
> |
try: self.EDG_retry_count = cfg_params['EDG.retry_count'] |
85 |
> |
except KeyError: self.EDG_retry_count = '' |
86 |
> |
|
87 |
> |
try: self.EDG_clock_time = cfg_params['EDG.max_wall_clock_time'] |
88 |
> |
except KeyError: self.EDG_clock_time= '' |
89 |
> |
|
90 |
> |
try: self.EDG_cpu_time = cfg_params['EDG.max_cpu_time'] |
91 |
> |
except KeyError: self.EDG_cpu_time = '' |
92 |
|
|
93 |
|
# Add EDG_WL_LOCATION to the python path |
94 |
|
|
103 |
|
libPath=os.path.join(path, "lib", "python") |
104 |
|
sys.path.append(libPath) |
105 |
|
|
106 |
< |
self.checkProxy_() |
106 |
> |
self.proxyValid=0 |
107 |
|
return |
108 |
|
|
109 |
+ |
|
110 |
+ |
def sched_parameter(self): |
111 |
+ |
""" |
112 |
+ |
Returns file with scheduler-specific parameters |
113 |
+ |
""" |
114 |
+ |
|
115 |
+ |
if (self.edg_config and self.edg_config_vo != ''): |
116 |
+ |
self.param='sched_param.clad' |
117 |
+ |
param_file = open(common.work_space.shareDir()+'/'+self.param, 'w') |
118 |
+ |
param_file.write('RBconfig = "'+self.edg_config+'";\n') |
119 |
+ |
param_file.write('RBconfigVO = "'+self.edg_config_vo+'";') |
120 |
+ |
param_file.close() |
121 |
+ |
return 1 |
122 |
+ |
else: |
123 |
+ |
return 0 |
124 |
+ |
|
125 |
|
def wsSetupEnvironment(self): |
126 |
|
""" |
127 |
|
Returns part of a job script which does scheduler-specific work. |
128 |
|
""" |
129 |
< |
txt = '\n' |
129 |
> |
|
130 |
> |
txt = '' |
131 |
> |
if int(self.copy_data) == 1: |
132 |
> |
if self.SE: |
133 |
> |
txt += 'export SE='+self.SE+'\n' |
134 |
> |
txt += 'echo "SE = $SE"\n' |
135 |
> |
if self.SE_PATH: |
136 |
> |
if ( self.SE_PATH[-1] != '/' ) : self.SE_PATH = self.SE_PATH + '/' |
137 |
> |
txt += 'export SE_PATH='+self.SE_PATH+'\n' |
138 |
> |
txt += 'echo "SE_PATH = $SE_PATH"\n' |
139 |
> |
|
140 |
> |
if int(self.register_data) == 1: |
141 |
> |
if self.VO: |
142 |
> |
txt += 'export VO='+self.VO+'\n' |
143 |
> |
if self.LFN: |
144 |
> |
txt += 'export LFN='+self.LFN+'\n' |
145 |
> |
txt += '\n' |
146 |
|
txt += 'CloseCEs=`edg-brokerinfo getCE`\n' |
147 |
|
txt += 'echo "CloseCEs = $CloseCEs"\n' |
148 |
|
txt += 'CE=`echo $CloseCEs | sed -e "s/:.*//"`\n' |
149 |
|
txt += 'echo "CE = $CE"\n' |
150 |
|
return txt |
151 |
|
|
152 |
+ |
def wsCopyOutput(self): |
153 |
+ |
""" |
154 |
+ |
Write a CopyResults part of a job script, e.g. |
155 |
+ |
to copy produced output into a storage element. |
156 |
+ |
""" |
157 |
+ |
txt = '' |
158 |
+ |
if int(self.copy_data) == 1: |
159 |
+ |
copy = 'globus-url-copy file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file' |
160 |
+ |
txt += '#\n' |
161 |
+ |
txt += '# Copy output to SE = $SE\n' |
162 |
+ |
txt += '#\n' |
163 |
+ |
txt += 'if [ $exe_result -eq 0 ]; then\n' |
164 |
+ |
txt += ' for out_file in $file_list ; do\n' |
165 |
+ |
txt += ' echo "Trying to copy output file to $SE "\n' |
166 |
+ |
txt += ' echo "'+copy+'"\n' |
167 |
+ |
txt += ' '+copy+' 2>&1\n' |
168 |
+ |
txt += ' copy_exit_status=$?\n' |
169 |
+ |
txt += ' echo "COPY_EXIT_STATUS = $copy_exit_status"\n' |
170 |
+ |
txt += ' echo "STAGE_OUT = $copy_exit_status"\n' |
171 |
+ |
txt += ' if [ $copy_exit_status -ne 0 ]; then \n' |
172 |
+ |
txt += ' echo "Problems with SE= $SE" \n' |
173 |
+ |
txt += ' else \n' |
174 |
+ |
txt += ' echo "output copied into $SE/$SE_PATH directory"\n' |
175 |
+ |
txt += ' fi \n' |
176 |
+ |
txt += ' done\n' |
177 |
+ |
txt += 'fi \n' |
178 |
+ |
return txt |
179 |
+ |
|
180 |
+ |
def wsRegisterOutput(self): |
181 |
+ |
""" |
182 |
+ |
Returns part of a job script which does scheduler-specific work. |
183 |
+ |
""" |
184 |
+ |
|
185 |
+ |
txt = '' |
186 |
+ |
if int(self.register_data) == 1: |
187 |
+ |
txt += '#\n' |
188 |
+ |
txt += '# Register output to RLS\n' |
189 |
+ |
txt += '#\n' |
190 |
+ |
txt += 'if [[ $exe_result -eq 0 && $copy_exit_status -eq 0 ]]; then\n' |
191 |
+ |
txt += ' for out_file in $file_list ; do\n' |
192 |
+ |
txt += ' echo "Trying to register the output file into RLS"\n' |
193 |
+ |
txt += ' echo "lcg-rf -l $LFN/$out_file --vo $VO sfn://$SE$SE_PATH/$out_file"\n' |
194 |
+ |
txt += ' lcg-rf -l $LFN/$out_file --vo $VO sfn://$SE$SE_PATH/$out_file 2>&1 \n' |
195 |
+ |
txt += ' register_exit_status=$?\n' |
196 |
+ |
txt += ' echo "REGISTER_EXIT_STATUS = $register_exit_status"\n' |
197 |
+ |
txt += ' echo "STAGE_OUT = $register_exit_status"\n' |
198 |
+ |
txt += ' if [ $register_exit_status -ne 0 ]; then \n' |
199 |
+ |
txt += ' echo "Problems with the registration to RLS" \n' |
200 |
+ |
txt += ' echo "Try with srm protocol" \n' |
201 |
+ |
txt += ' echo "lcg-rf -l $LFN/$out_file --vo $VO srm://$SE$SE_PATH/$out_file"\n' |
202 |
+ |
txt += ' lcg-rf -l $LFN/$out_file --vo $VO srm://$SE$SE_PATH/$out_file 2>&1 \n' |
203 |
+ |
txt += ' register_exit_status=$?\n' |
204 |
+ |
txt += ' echo "REGISTER_EXIT_STATUS = $register_exit_status"\n' |
205 |
+ |
txt += ' echo "STAGE_OUT = $register_exit_status"\n' |
206 |
+ |
txt += ' if [ $register_exit_status -ne 0 ]; then \n' |
207 |
+ |
txt += ' echo "Problems with the registration into RLS" \n' |
208 |
+ |
txt += ' fi \n' |
209 |
+ |
txt += ' else \n' |
210 |
+ |
txt += ' echo "output registered to RLS"\n' |
211 |
+ |
txt += ' fi \n' |
212 |
+ |
txt += ' done\n' |
213 |
+ |
txt += 'elif [[ $exe_result -eq 0 && $copy_exit_status -ne 0 ]]; then \n' |
214 |
+ |
txt += ' echo "Trying to copy output file to CloseSE"\n' |
215 |
+ |
txt += ' CLOSE_SE=`edg-brokerinfo getCloseSEs | head -1`\n' |
216 |
+ |
txt += ' for out_file in $file_list ; do\n' |
217 |
+ |
txt += ' echo "lcg-cr -v -l lfn:${LFN}/$out_file -d $CLOSE_SE -P $LFN/$out_file --vo $VO file://`pwd`/$out_file" \n' |
218 |
+ |
txt += ' lcg-cr -v -l lfn:${LFN}/$out_file -d $CLOSE_SE -P $LFN/$out_file --vo $VO file://`pwd`/$out_file 2>&1 \n' |
219 |
+ |
txt += ' register_exit_status=$?\n' |
220 |
+ |
txt += ' echo "REGISTER_EXIT_STATUS = $register_exit_status"\n' |
221 |
+ |
txt += ' echo "STAGE_OUT = $register_exit_status"\n' |
222 |
+ |
txt += ' if [ $register_exit_status -ne 0 ]; then \n' |
223 |
+ |
txt += ' echo "Problems with CloseSE" \n' |
224 |
+ |
txt += ' else \n' |
225 |
+ |
txt += ' echo "The program was successfully executed"\n' |
226 |
+ |
txt += ' echo "SE = $CLOSE_SE"\n' |
227 |
+ |
txt += ' echo "LFN for the file is LFN=${LFN}/$out_file"\n' |
228 |
+ |
txt += ' fi \n' |
229 |
+ |
txt += ' done\n' |
230 |
+ |
txt += 'else\n' |
231 |
+ |
txt += ' echo "Problem with the executable"\n' |
232 |
+ |
txt += 'fi \n' |
233 |
+ |
return txt |
234 |
+ |
|
235 |
+ |
def loggingInfo(self, id): |
236 |
+ |
""" |
237 |
+ |
retrieve the logging info from logging and bookkeeping and return it |
238 |
+ |
""" |
239 |
+ |
self.checkProxy() |
240 |
+ |
# id = common.jobDB.jobId(nj) |
241 |
+ |
cmd = 'edg-job-get-logging-info -v 2 ' + id |
242 |
+ |
cmd_out = os.popen(cmd) |
243 |
+ |
# cmd_out = runCommand(cmd) |
244 |
+ |
return cmd_out |
245 |
+ |
|
246 |
+ |
def listMatch(self, nj): |
247 |
+ |
""" |
248 |
+ |
Check the compatibility of available resources |
249 |
+ |
""" |
250 |
+ |
self.checkProxy() |
251 |
+ |
jdl = common.job_list[nj].jdlFilename() |
252 |
+ |
cmd = 'edg-job-list-match ' + self.configOpt_() + jdl |
253 |
+ |
# myCmd = os.popen(cmd) |
254 |
+ |
# cmd_out = myCmd.readlines() |
255 |
+ |
# myCmd.close() |
256 |
+ |
cmd_out = runCommand(cmd,0,240) |
257 |
+ |
return self.parseListMatch_(cmd_out, jdl) |
258 |
+ |
|
259 |
+ |
def parseListMatch_(self, out, jdl): |
260 |
+ |
""" |
261 |
+ |
Parse the f* output of edg-list-match and produce something sensible |
262 |
+ |
""" |
263 |
+ |
reComment = re.compile( r'^\**$' ) |
264 |
+ |
reEmptyLine = re.compile( r'^$' ) |
265 |
+ |
reVO = re.compile( r'Selected Virtual Organisation name.*' ) |
266 |
+ |
reLine = re.compile( r'.*') |
267 |
+ |
reCE = re.compile( r'(.*:.*)') |
268 |
+ |
reCEId = re.compile( r'CEId.*') |
269 |
+ |
reNO = re.compile( r'No Computing Element matching' ) |
270 |
+ |
reRB = re.compile( r'Connecting to host' ) |
271 |
+ |
next = 0 |
272 |
+ |
CEs=[] |
273 |
+ |
Match=0 |
274 |
+ |
|
275 |
+ |
#print out |
276 |
+ |
lines = reLine.findall(out) |
277 |
+ |
|
278 |
+ |
i=0 |
279 |
+ |
CEs=[] |
280 |
+ |
for line in lines: |
281 |
+ |
string.strip(line) |
282 |
+ |
#print line |
283 |
+ |
if reNO.match( line ): |
284 |
+ |
common.logger.debug(5,line) |
285 |
+ |
return 0 |
286 |
+ |
pass |
287 |
+ |
if reVO.match( line ): |
288 |
+ |
VO =reVO.match( line ).group() |
289 |
+ |
common.logger.debug(5,"VO "+VO) |
290 |
+ |
pass |
291 |
+ |
|
292 |
+ |
if reRB.match( line ): |
293 |
+ |
RB = reRB.match(line).group() |
294 |
+ |
common.logger.debug(5,"RB "+RB) |
295 |
+ |
pass |
296 |
+ |
|
297 |
+ |
if reCEId.search( line ): |
298 |
+ |
for lineCE in lines[i:-1]: |
299 |
+ |
if reCE.match( lineCE ): |
300 |
+ |
CE = string.strip(reCE.search(lineCE).group(1)) |
301 |
+ |
CEs.append(CE.split(':')[0]) |
302 |
+ |
pass |
303 |
+ |
pass |
304 |
+ |
pass |
305 |
+ |
i=i+1 |
306 |
+ |
pass |
307 |
+ |
|
308 |
+ |
common.logger.debug(5,"All CE :"+str(CEs)) |
309 |
+ |
|
310 |
+ |
sites = [] |
311 |
+ |
[sites.append(it) for it in CEs if not sites.count(it)] |
312 |
+ |
|
313 |
+ |
common.logger.debug(5,"All Sites :"+str(sites)) |
314 |
+ |
return len(sites) |
315 |
+ |
|
316 |
+ |
def noMatchFound_(self, jdl): |
317 |
+ |
reReq = re.compile( r'Requirements' ) |
318 |
+ |
reString = re.compile( r'"\S*"' ) |
319 |
+ |
f = file(jdl,'r') |
320 |
+ |
for line in f.readlines(): |
321 |
+ |
line= line.strip() |
322 |
+ |
if reReq.match(line): |
323 |
+ |
for req in reString.findall(line): |
324 |
+ |
if re.search("VO",req): |
325 |
+ |
common.logger.message( "SW required: "+req) |
326 |
+ |
continue |
327 |
+ |
if re.search('"\d+',req): |
328 |
+ |
common.logger.message("Other req : "+req) |
329 |
+ |
continue |
330 |
+ |
common.logger.message( "CE required: "+req) |
331 |
+ |
break |
332 |
+ |
pass |
333 |
+ |
raise CrabException("No compatible resources found!") |
334 |
+ |
|
335 |
|
def submit(self, nj): |
336 |
|
""" |
337 |
|
Submit one EDG job. |
338 |
|
""" |
339 |
|
|
340 |
+ |
self.checkProxy() |
341 |
|
jid = None |
342 |
|
jdl = common.job_list[nj].jdlFilename() |
343 |
< |
id_tmp = tempfile.mktemp() |
344 |
< |
edg_ui_cfg_opt = ' ' |
81 |
< |
if self.edg_config: |
82 |
< |
edg_ui_cfg_opt = ' -c ' + self.edg_config + ' ' |
83 |
< |
if self.edg_config_vo: |
84 |
< |
edg_ui_cfg_opt += ' --config-vo ' + self.edg_config_vo + ' ' |
85 |
< |
cmd = 'edg-job-submit -o ' + id_tmp + edg_ui_cfg_opt + jdl |
343 |
> |
|
344 |
> |
cmd = 'edg-job-submit ' + self.configOpt_() + jdl |
345 |
|
cmd_out = runCommand(cmd) |
346 |
|
if cmd_out != None: |
347 |
< |
idfile = open(id_tmp) |
348 |
< |
jid_line = idfile.readline() |
90 |
< |
while jid_line[0] == '#': |
91 |
< |
jid_line = idfile.readline() |
92 |
< |
pass |
93 |
< |
jid = string.strip(jid_line) |
94 |
< |
os.unlink(id_tmp) |
347 |
> |
reSid = re.compile( r'https.+' ) |
348 |
> |
jid = reSid.search(cmd_out).group() |
349 |
|
pass |
350 |
|
return jid |
351 |
|
|
352 |
+ |
def getExitStatus(self, id): |
353 |
+ |
return self.getStatusAttribute_(id, 'exit_code') |
354 |
+ |
|
355 |
|
def queryStatus(self, id): |
356 |
+ |
return self.getStatusAttribute_(id, 'status') |
357 |
+ |
|
358 |
+ |
def queryDest(self, id): |
359 |
+ |
return self.getStatusAttribute_(id, 'destination') |
360 |
+ |
|
361 |
+ |
|
362 |
+ |
def getStatusAttribute_(self, id, attr): |
363 |
|
""" Query a status of the job with id """ |
364 |
< |
cmd0 = 'edg-job-status ' |
365 |
< |
cmd = cmd0 + id |
366 |
< |
cmd_out = runCommand(cmd) |
367 |
< |
if cmd_out == None: |
368 |
< |
common.logger.message('Error. No output from `'+cmd+'`') |
369 |
< |
return None |
370 |
< |
# parse output |
371 |
< |
status_prefix = 'Current Status:' |
372 |
< |
status_index = string.find(cmd_out, status_prefix) |
373 |
< |
if status_index == -1: |
374 |
< |
common.logger.message('Error. Bad output of `'+cmd0+'`:\n'+cmd_out) |
364 |
> |
|
365 |
> |
self.checkProxy() |
366 |
> |
hstates = {} |
367 |
> |
Status = importName('edg_wl_userinterface_common_LbWrapper', 'Status') |
368 |
> |
# Bypass edg-job-status interfacing directly to C++ API |
369 |
> |
# Job attribute vector to retrieve status without edg-job-status |
370 |
> |
level = 0 |
371 |
> |
# Instance of the Status class provided by LB API |
372 |
> |
jobStat = Status() |
373 |
> |
st = 0 |
374 |
> |
jobStat.getStatus(id, level) |
375 |
> |
err, apiMsg = jobStat.get_error() |
376 |
> |
if err: |
377 |
> |
common.logger.debug(5,'Error caught' + apiMsg) |
378 |
|
return None |
379 |
< |
status = cmd_out[(status_index+len(status_prefix)):] |
380 |
< |
nl = string.find(status,'\n') |
381 |
< |
status = string.strip(status[0:nl]) |
382 |
< |
return status |
379 |
> |
else: |
380 |
> |
for i in range(len(self.states)): |
381 |
> |
# Fill an hash table with all information retrieved from LB API |
382 |
> |
hstates[ self.states[i] ] = jobStat.loadStatus(st)[i] |
383 |
> |
result = jobStat.loadStatus(st)[ self.states.index(attr) ] |
384 |
> |
return result |
385 |
|
|
386 |
|
def queryDetailedStatus(self, id): |
387 |
|
""" Query a detailed status of the job with id """ |
394 |
|
Get output for a finished job with id. |
395 |
|
Returns the name of directory with results. |
396 |
|
""" |
397 |
< |
cmd = 'edg-job-get-output --dir ' + common.work_space.resDir() +' '+id |
397 |
> |
|
398 |
> |
self.checkProxy() |
399 |
> |
cmd = 'edg-job-get-output --dir ' + common.work_space.resDir() + ' ' + id |
400 |
|
cmd_out = runCommand(cmd) |
401 |
|
|
402 |
|
# Determine the output directory name |
407 |
|
|
408 |
|
def cancel(self, id): |
409 |
|
""" Cancel the EDG job with id """ |
410 |
+ |
self.checkProxy() |
411 |
|
cmd = 'edg-job-cancel --noint ' + id |
412 |
|
cmd_out = runCommand(cmd) |
413 |
|
return cmd_out |
414 |
|
|
415 |
< |
def checkProxy_(self): |
144 |
< |
""" |
145 |
< |
Function to check the Globus proxy. |
146 |
< |
""" |
147 |
< |
cmd = 'grid-proxy-info -timeleft' |
148 |
< |
cmd_out = runCommand(cmd) |
149 |
< |
ok = 1 |
150 |
< |
timeleft = -999 |
151 |
< |
try: timeleft = int(cmd_out) |
152 |
< |
except ValueError: ok=0 |
153 |
< |
except TypeError: ok=0 |
154 |
< |
if timeleft < 1: ok=0 |
155 |
< |
|
156 |
< |
if ok==0: |
157 |
< |
msg = 'No valid proxy found !\n' |
158 |
< |
msg += "Please do 'grid-proxy-init'." |
159 |
< |
raise CrabException(msg) |
160 |
< |
return |
161 |
< |
|
162 |
< |
def createJDL(self, nj): |
415 |
> |
def createSchScript(self, nj): |
416 |
|
""" |
417 |
|
Create a JDL-file for EDG. |
418 |
|
""" |
419 |
|
|
420 |
|
job = common.job_list[nj] |
421 |
|
jbt = job.type() |
169 |
– |
# jbt.loadJobInfo() |
422 |
|
inp_sandbox = jbt.inputSandbox(nj) |
423 |
|
out_sandbox = jbt.outputSandbox(nj) |
424 |
< |
inp_storage_subdir = ''#jbt.inputStorageSubdir() |
424 |
> |
inp_storage_subdir = '' |
425 |
|
|
426 |
|
title = '# This JDL was generated by '+\ |
427 |
|
common.prog_name+' (version '+common.prog_version_str+')\n' |
428 |
|
jt_string = '' |
429 |
+ |
|
430 |
+ |
|
431 |
|
|
432 |
|
SPL = inp_storage_subdir |
433 |
|
if ( SPL and SPL[-1] != '/' ) : SPL = SPL + '/' |
440 |
|
jdl.write('Executable = "' + os.path.basename(script) +'";\n') |
441 |
|
jdl.write(jt_string) |
442 |
|
|
443 |
+ |
### only one .sh JDL has arguments: |
444 |
+ |
firstEvent = common.jobDB.firstEvent(nj) |
445 |
+ |
maxEvents = common.jobDB.maxEvents(nj) |
446 |
+ |
jdl.write('Arguments = "' + str(nj+1)+' '+str(firstEvent)+' '+str(maxEvents)+'";\n') |
447 |
+ |
|
448 |
|
inp_box = 'InputSandbox = { ' |
449 |
|
inp_box = inp_box + '"' + script + '",' |
450 |
|
|
457 |
|
#if common.use_jam: |
458 |
|
# inp_box = inp_box+' "'+common.bin_dir+'/'+common.run_jam+'",' |
459 |
|
|
460 |
< |
# ??? Should be local, i.e. self.additional_inbox_files |
461 |
< |
# and filled in ctor from cfg_params |
462 |
< |
#for addFile in common.additional_inbox_files: |
463 |
< |
# addFile = os.path.abspath(addFile) |
205 |
< |
# inp_box = inp_box+' "'+addFile+'",' |
206 |
< |
# pass |
460 |
> |
for addFile in jbt.additional_inbox_files: |
461 |
> |
addFile = os.path.abspath(addFile) |
462 |
> |
inp_box = inp_box+' "'+addFile+'",' |
463 |
> |
pass |
464 |
|
|
465 |
|
if inp_box[-1] == ',' : inp_box = inp_box[:-1] |
466 |
|
inp_box = inp_box + ' };\n' |
468 |
|
|
469 |
|
jdl.write('StdOutput = "' + job.stdout() + '";\n') |
470 |
|
jdl.write('StdError = "' + job.stderr() + '";\n') |
471 |
< |
|
472 |
< |
|
216 |
< |
### SL check if stdout==stderr: in case put just one in the out_box |
471 |
> |
|
472 |
> |
|
473 |
|
if job.stdout() == job.stderr(): |
474 |
|
out_box = 'OutputSandbox = { "' + \ |
475 |
|
job.stdout() + '", ".BrokerInfo",' |
477 |
|
out_box = 'OutputSandbox = { "' + \ |
478 |
|
job.stdout() + '", "' + \ |
479 |
|
job.stderr() + '", ".BrokerInfo",' |
224 |
– |
pass |
480 |
|
|
481 |
< |
#if common.flag_return_data : |
482 |
< |
# for fl in job.outputDataFiles(): |
483 |
< |
# out_box = out_box + ' "' + fl + '",' |
484 |
< |
# pass |
485 |
< |
# pass |
231 |
< |
|
232 |
< |
if out_sandbox != None: |
233 |
< |
for fl in out_sandbox: |
234 |
< |
out_box = out_box + ' "' + fl + '",' |
481 |
> |
if int(self.return_data) == 1: |
482 |
> |
if out_sandbox != None: |
483 |
> |
for fl in out_sandbox: |
484 |
> |
out_box = out_box + ' "' + fl + '",' |
485 |
> |
pass |
486 |
|
pass |
487 |
|
pass |
488 |
< |
|
488 |
> |
|
489 |
|
if out_box[-1] == ',' : out_box = out_box[:-1] |
490 |
|
out_box = out_box + ' };' |
491 |
|
jdl.write(out_box+'\n') |
492 |
|
|
493 |
< |
# If CloseCE is used ... |
243 |
< |
#if common.flag_usecloseCE and job.inputDataFiles(): |
244 |
< |
# indata = 'InputData = { ' |
245 |
< |
# for fl in job.inputDataFiles(): |
246 |
< |
# indata = indata + ' "lfn:' + SPL + fl + '",' |
247 |
< |
# if indata[-1] == ',' : indata = indata[:-1] |
248 |
< |
# indata = indata + ' };' |
249 |
< |
# jdl.write(indata+'\n') |
250 |
< |
# jdl.write('DataAccessProtocol = { "gsiftp" };\n') |
251 |
< |
|
493 |
> |
### if at least a CE exists ... |
494 |
|
if common.analisys_common_info['sites']: |
495 |
< |
if common.analisys_common_info['sw_version']: |
496 |
< |
|
497 |
< |
req='Requirements = ' |
498 |
< |
### First ORCA version |
499 |
< |
req=req + 'Member("VO-cms-' + \ |
500 |
< |
common.analisys_common_info['sw_version'] + \ |
501 |
< |
'", other.GlueHostApplicationSoftwareRunTimeEnvironment)' |
502 |
< |
## then sites |
503 |
< |
if len(common.analisys_common_info['sites'])>0: |
504 |
< |
req = req + ' && (' |
505 |
< |
for i in range(len(common.analisys_common_info['sites'])): |
506 |
< |
req = req + 'other.GlueCEInfoHostName == "' \ |
507 |
< |
+ common.analisys_common_info['sites'][i] + '"' |
508 |
< |
if ( i < (int(len(common.analisys_common_info['sites']) - 1)) ): |
509 |
< |
req = req + ' || ' |
510 |
< |
req = req + ')' |
511 |
< |
## then user requirement |
512 |
< |
if self.EDG_requirements: |
513 |
< |
req = req + ' && ' + self.EDG_requirements |
514 |
< |
req = req + ';\n' |
515 |
< |
jdl.write(req) |
516 |
< |
|
495 |
> |
if common.analisys_common_info['sw_version']: |
496 |
> |
req='Requirements = ' |
497 |
> |
req=req + 'Member("VO-cms-' + \ |
498 |
> |
common.analisys_common_info['sw_version'] + \ |
499 |
> |
'", other.GlueHostApplicationSoftwareRunTimeEnvironment)' |
500 |
> |
if len(common.analisys_common_info['sites'])>0: |
501 |
> |
req = req + ' && (' |
502 |
> |
for i in range(len(common.analisys_common_info['sites'])): |
503 |
> |
req = req + 'other.GlueCEInfoHostName == "' \ |
504 |
> |
+ common.analisys_common_info['sites'][i] + '"' |
505 |
> |
if ( i < (int(len(common.analisys_common_info['sites']) - 1)) ): |
506 |
> |
req = req + ' || ' |
507 |
> |
req = req + ')' |
508 |
> |
|
509 |
> |
#### and USER REQUIREMENT |
510 |
> |
if self.EDG_requirements: |
511 |
> |
req = req + ' && ' + self.EDG_requirements |
512 |
> |
if self.EDG_clock_time: |
513 |
> |
req = req + ' && other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time |
514 |
> |
if self.EDG_cpu_time: |
515 |
> |
req = req + ' && other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time |
516 |
> |
req = req + ';\n' |
517 |
> |
jdl.write(req) |
518 |
> |
|
519 |
|
jdl.write('VirtualOrganisation = "' + self.VO + '";\n') |
520 |
|
|
521 |
|
if ( self.EDG_retry_count ): |
524 |
|
|
525 |
|
jdl.close() |
526 |
|
return |
527 |
+ |
|
528 |
+ |
def checkProxy(self): |
529 |
+ |
""" |
530 |
+ |
Function to check the Globus proxy. |
531 |
+ |
""" |
532 |
+ |
if (self.proxyValid): return |
533 |
+ |
timeleft = -999 |
534 |
+ |
minTimeLeft=10 # in hours |
535 |
+ |
cmd = 'grid-proxy-info -e -v '+str(minTimeLeft)+':00' |
536 |
+ |
try: cmd_out = runCommand(cmd,0) |
537 |
+ |
except: print cmd_out |
538 |
+ |
if (cmd_out == None or cmd_out=='1'): |
539 |
+ |
common.logger.message( "No valid proxy found or timeleft too short!\n Creating a user proxy with default length of 100h\n") |
540 |
+ |
cmd = 'grid-proxy-init -valid 100:00' |
541 |
+ |
try: |
542 |
+ |
out = os.system(cmd) |
543 |
+ |
if (out>0): raise CrabException("Unable to create a valid proxy!\n") |
544 |
+ |
except: |
545 |
+ |
msg = "Unable to create a valid proxy!\n" |
546 |
+ |
raise CrabException(msg) |
547 |
+ |
cmd = 'grid-proxy-info -timeleft' |
548 |
+ |
cmd_out = runCommand(cmd,0) |
549 |
+ |
pass |
550 |
+ |
self.proxyValid=1 |
551 |
+ |
return |
552 |
+ |
|
553 |
+ |
def configOpt_(self): |
554 |
+ |
edg_ui_cfg_opt = ' ' |
555 |
+ |
if self.edg_config: |
556 |
+ |
edg_ui_cfg_opt = ' -c ' + self.edg_config + ' ' |
557 |
+ |
if self.edg_config_vo: |
558 |
+ |
edg_ui_cfg_opt += ' --config-vo ' + self.edg_config_vo + ' ' |
559 |
+ |
return edg_ui_cfg_opt |