1 |
– |
from crab_logger import Logger |
1 |
|
from crab_exceptions import * |
2 |
|
from crab_util import * |
3 |
|
import common |
57 |
|
try: |
58 |
|
task = common.bossSession.load(1,jobsList) |
59 |
|
except Exception, e : |
60 |
< |
common.logger.debug(3, "Error while getting task : " +str(traceback.format_exc())) |
60 |
> |
common.logger.debug( "Error while getting task : " +str(traceback.format_exc())) |
61 |
|
raise CrabException('Error while getting task '+str(e)) |
62 |
|
return task |
63 |
|
|
68 |
|
try: |
69 |
|
task = common.bossSession.load(1,str(n)) |
70 |
|
except Exception, e : |
71 |
< |
common.logger.debug(3, "Error while getting job : " +str(traceback.format_exc())) |
71 |
> |
common.logger.debug( "Error while getting job : " +str(traceback.format_exc())) |
72 |
|
raise CrabException('Error while getting job '+str(e)) |
73 |
|
return task |
74 |
|
|
80 |
|
""" |
81 |
|
opt={} |
82 |
|
if optsToSave.get('server_mode',0) == 1: opt['serverName']=optsToSave['server_name'] |
83 |
< |
opt['name']=common.work_space.taskName() |
83 |
> |
opt['name']= getUserName()+ '_' + string.split(common.work_space.topDir(),'/')[-2]+'_'+common.work_space.task_uuid() |
84 |
|
task = Task( opt ) |
85 |
|
try: |
86 |
|
common.bossSession.saveTask( task ) |
87 |
|
except Exception, e : |
89 |
– |
# common.logger.debug(3, "Error creating task : " +str(traceback.format_exc())) |
90 |
– |
# raise CrabException('Error creating task '+str(e)) |
88 |
|
raise CrabException('Error creating task '+str(traceback.format_exc())) |
89 |
|
|
90 |
|
return |
204 |
|
lines=[] |
205 |
|
task = self.getTask() |
206 |
|
if server_mode == 1: |
207 |
< |
headerTask= "Task Id = %-40s " %(task['name']) |
207 |
> |
# init client server params... |
208 |
> |
CliServerParams(self) |
209 |
> |
headerTask = "Task Id = %-40s\n" %(task['name']) |
210 |
> |
headerTask+= '--------------------------------------------------------------------------------------------\n' |
211 |
|
displayReport(self,headerTask,lines) |
212 |
+ |
common.logger.info(showWebMon(self.server_name)) |
213 |
|
if (jid ) or (server_mode == 0): |
214 |
|
for job in task.jobs: |
215 |
|
toPrint='' |
216 |
|
common.bossSession.getRunningInstance(job) |
217 |
|
toPrint = "%-5s %-50s " % (job['jobId'],job.runningJob['schedulerId']) |
218 |
|
lines.append(toPrint) |
219 |
< |
header+= "%-5s %-50s " % ('Job:','ID' ) |
219 |
> |
header+= "%-5s %-50s\n " % ('Job:','ID' ) |
220 |
> |
header+= '--------------------------------------------------------------------------------------------\n' |
221 |
|
displayReport(self,header,lines) |
222 |
|
return |
223 |
|
|
259 |
|
try: |
260 |
|
task = common.bossSession.loadJobDist( 1, attr ) |
261 |
|
except Exception, e : |
262 |
< |
common.logger.debug(3, "Error loading Jobs By distinct Attr : " +str(traceback.format_exc())) |
262 |
> |
common.logger.debug( "Error loading Jobs By distinct Attr : " +str(traceback.format_exc())) |
263 |
|
raise CrabException('Error loading Jobs By distinct Attr '+str(e)) |
264 |
|
|
265 |
|
for i in task: distAttr.append(i[attr]) |
273 |
|
try: |
274 |
|
task = common.bossSession.loadJobDistAttr( 1, attr_1, attr_2, list ) |
275 |
|
except Exception, e : |
276 |
< |
common.logger.debug(3, "Error loading Jobs By distinct Attr : " +str(traceback.format_exc())) |
276 |
> |
common.logger.debug( "Error loading Jobs By distinct Attr : " +str(traceback.format_exc())) |
277 |
|
raise CrabException('Error loading Jobs By distinct Attr '+str(e)) |
278 |
|
|
279 |
|
for i in task: distAttr.append(i[attr_1]) |
287 |
|
try: |
288 |
|
task = common.bossSession.loadJobsByAttr(attr ) |
289 |
|
except Exception, e : |
290 |
< |
common.logger.debug(3, "Error loading Jobs By Attr : " +str(traceback.format_exc())) |
290 |
> |
common.logger.debug( "Error loading Jobs By Attr : " +str(traceback.format_exc())) |
291 |
|
raise CrabException('Error loading Jobs By Attr '+str(e)) |
292 |
|
for i in task: |
293 |
|
matched.append(i[field]) |
302 |
|
try: |
303 |
|
task = common.bossSession.loadJobsByRunningAttr(attr) |
304 |
|
except Exception, e : |
305 |
< |
common.logger.debug(3, "Error loading Jobs By Running Attr : " +str(traceback.format_exc())) |
305 |
> |
common.logger.debug( "Error loading Jobs By Running Attr : " +str(traceback.format_exc())) |
306 |
|
raise CrabException('Error loading Jobs By Running Attr '+str(e)) |
307 |
|
for i in task: |
308 |
|
matched.append(i.runningJob[field]) |
318 |
|
common.bossSession.getNewRunningInstance(job) |
319 |
|
job.runningJob['status'] = 'C' |
320 |
|
job.runningJob['statusScheduler'] = 'Created' |
321 |
+ |
job.runningJob['state'] = 'Created' |
322 |
|
common.bossSession.updateDB(task) |
323 |
|
return |
324 |
|
|
325 |
|
def deserXmlStatus(self, reportList): |
326 |
|
|
327 |
|
task = self.getTask() |
328 |
+ |
if int(self.cfg_params.get('WMBS.automation',0)) == 1: |
329 |
+ |
if len(reportList) ==0: |
330 |
+ |
msg = 'You are using CRAB with WMBS the server is still creating your jobs.\n' |
331 |
+ |
msg += '\tPlease wait...' |
332 |
+ |
raise CrabException(msg) |
333 |
+ |
newJobs = len(reportList) - len(task.jobs) |
334 |
+ |
if newJobs != 0: |
335 |
+ |
isNew=True |
336 |
+ |
if len(task.jobs):isNew=False |
337 |
+ |
jobL=[] |
338 |
+ |
for i in range(1,newJobs+1): |
339 |
+ |
jobL.append(len(task.jobs)+i) |
340 |
+ |
self.createJobs_(jobL,isNew) |
341 |
+ |
|
342 |
|
for job in task.jobs: |
343 |
|
if not job.runningJob: |
344 |
|
raise CrabException( "Missing running object for job %s"%str(job['jobId']) ) |
350 |
|
if r.getAttribute('id') in [ id, 'all']: |
351 |
|
rForJ = r |
352 |
|
break |
353 |
< |
## Check the submission number and create new running jobs on the client side |
354 |
< |
if rForJ.getAttribute('resubmit') != 'None' and (rForJ.getAttribute('status') not in ['Cleared','Killed','Done','Done (Failed)']) : |
353 |
> |
## Check the submission number and create new running jobs on the client side |
354 |
> |
if rForJ.getAttribute('resubmit') != 'None' and (rForJ.getAttribute('status') not in ['Cleared','Killed','Done','Done (Failed)','Not Submitted', 'Cancelled by user']) : |
355 |
|
if int(job.runningJob['submission']) < int(rForJ.getAttribute('resubmit')) + 1: |
356 |
|
nj_list.append(id) |
357 |
|
if len(nj_list) > 0: self.newRunJobs(nj_list) |
365 |
|
for r in reportList: |
366 |
|
if r.getAttribute('id') in [ id, 'all']: |
367 |
|
rForJ = r |
368 |
< |
break |
368 |
> |
break |
369 |
|
|
370 |
|
# Data alignment |
371 |
< |
if rForJ.getAttribute('status') not in ['Created', 'Unknown']: |
371 |
> |
if rForJ.getAttribute('status') not in ['Unknown']: # ['Created', 'Unknown']: |
372 |
|
# update the status |
373 |
< |
common.logger.debug(3,"Updating DB status for job: " + str(id) + " @: " \ |
373 |
> |
common.logger.debug("Updating DB status for job: " + str(id) + " @: " \ |
374 |
|
+ str(rForJ.getAttribute('status')) ) |
375 |
|
job.runningJob['statusScheduler'] = str( rForJ.getAttribute('status') ) |
376 |
|
if (rForJ.getAttribute('status') == 'Done' or rForJ.getAttribute('status') == 'Done (Failed)')\ |
389 |
|
|
390 |
|
job.runningJob['wrapperReturnCode'] = str( rForJ.getAttribute('job_exit') ) |
391 |
|
job_exit_code = str(job.runningJob['wrapperReturnCode']) |
392 |
+ |
|
393 |
+ |
job['closed'] = str( rForJ.getAttribute('ended') ) |
394 |
+ |
|
395 |
+ |
job.runningJob['state'] = str( rForJ.getAttribute('action') ) |
396 |
|
|
397 |
< |
#if str( rForJ.getAttribute('resubmit') ).isdigit(): |
398 |
< |
# job['submissionNumber'] = int(rForJ.getAttribute('resubmit')) |
378 |
< |
# job.runningJob['submission'] = int(rForJ.getAttribute('resubmit')) |
397 |
> |
# Needed for unique naming of the output |
398 |
> |
job.runningJob['submission'] = int(rForJ.getAttribute('submission')) |
399 |
|
|
380 |
– |
# TODO cleared='0' field, how should it be handled/mapped in BL? #Fabio |
381 |
– |
|
400 |
|
common.bossSession.updateDB( task_new ) |
401 |
|
return |
402 |
|
|
403 |
|
# FIXME temporary method to verify what kind of submission to perform towards the server |
404 |
|
def checkIfNeverSubmittedBefore(self): |
405 |
|
for j in self.getTask().jobs: |
406 |
< |
if j.runningJob['submission'] > 1 or j.runningJob['status'] != 'C' or \ |
389 |
< |
j.runningJob['statusScheduler'] != 'Created': |
406 |
> |
if j.runningJob['submission'] > 1 or j.runningJob['state'] != 'Created': |
407 |
|
return False |
408 |
|
return True |
409 |
|
|
410 |
+ |
# Method to update arguments w.r.t. resubmission number in order to grant unique output |
411 |
+ |
def updateResubAttribs(self, jobsL): |
412 |
+ |
task = self.getTask(jobsL) |
413 |
+ |
for j in task.jobs: |
414 |
+ |
common.bossSession.getRunningInstance(j) |
415 |
+ |
newArgs = "%d %d"%(j.runningJob['jobId'], j.runningJob['submission']) |
416 |
+ |
j['arguments'] = newArgs |
417 |
+ |
|
418 |
+ |
common.bossSession.updateDB(task) |
419 |
+ |
return |
420 |
+ |
|
421 |
|
|