Package Ganga :: Package Lib :: Package MonitoringServices :: Package Dashboard :: Module BatchUtil
[hide private]
[frames] | no frames]

Source Code for Module Ganga.Lib.MonitoringServices.Dashboard.BatchUtil

 1  """Batch meta-data utilities. 
 2   
 3  N.B. This code is under development and should not generally be used or relied upon. 
 4   
 5  """ 
 6   
 7  from Ganga.Lib.MonitoringServices.Dashboard import CommonUtil 
 8   
 9  #----- client meta-data builders -----  
10  #TODO: add error handling code in following methods 
11   
12 -def cl_dest_ce(job):
13 """Build dest_ce. Only run on client.""" 14 return CommonUtil.strip_to_none(job.backend.actualCE)
15
16 -def cl_execution_backend(job):
17 """Build execution_backend. Only run on client.""" 18 return job.backend._name
19
20 -def cl_grid_exit_code(job):
21 """Build grid_exit_code. Only run on client.""" 22 return CommonUtil.strip_to_none(job.backend.exitcode)
23
24 -def cl_grid_exit_reason(job):
25 """Build grid_exit_reason. Only run on client.""" 26 return None
27
28 -def cl_grid_job_id(job):
29 """Build grid_job_id. Only run on client.""" 30 return CommonUtil.strip_to_none(job.backend.id)
31
32 -def cl_ownerdn():
33 """Build ownerdn. Only run on client.""" 34 from Ganga.GPIDev import Credentials 35 proxy = Credentials.getCredential('GridProxy') 36 ownerdn = proxy.info('-subject') 37 return CommonUtil.strip_to_none(ownerdn)
38
39 -def cl_grid_status(job):
40 """Build grid_status. Only run on client.""" 41 return CommonUtil.strip_to_none(job.backend.status)
42
43 -def cl_job_id_inside_the_task(job):
44 """Build job_id_inside_the_task. Only run on client.""" 45 if job.master is None: 46 job_id_inside_the_task = 0 47 else: 48 job_id_inside_the_task = job.id 49 return job_id_inside_the_task
50
51 -def cl_task_name(job):
52 """Build task_name. Only run on client.""" 53 # format: ganga:<job.info.uuid>:<job.name> 54 if job.master: 55 job = job.master 56 task_name = 'ganga:%s:%s' % (job.info.uuid, job.name,) 57 return task_name
58
59 -def cl_unique_job_id(job):
60 """Build unique_job_id. Only run on client.""" 61 return job.info.uuid
62 63 #----- worker node meta-data builders ----- 64 #TODO: add error handling code in following methods 65 66 67 #retrieve site name from ip adress
68 -def wn_dest_site(ji):
69 """Build dest_site. Only run on worker node.""" 70 return ji['GANGA_HOSTNAME']
71 #this is ok
72 -def wn_dest_wn():
73 """Build dest_wn. Only run on worker node.""" 74 return CommonUtil.hostname()
75 #return something like task name
76 -def wn_grid_job_id(ji):
77 """Build grid_job_id. Only run on worker node.""" 78 task_name = 'ganga:%s:%s' % (ji['JOB_UUID'], ji['JOB_NAME'],) 79 return task_name
80