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

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

 1  """Athena 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_application(job):
13 """Build application. Only run on client.""" 14 return CommonUtil.strip_to_none(job.application.atlas_exetype)
15
16 -def cl_application_version(job):
17 """Build application_version. Only run on client.""" 18 if job.application.atlas_production: 19 application_version = job.application.atlas_production 20 else: 21 application_version = job.application.atlas_release 22 return CommonUtil.strip_to_none(application_version)
23
24 -def cl_input_dataset(job):
25 """Build input_dataset. Only run on client.""" 26 if not job.inputdata: return None 27 datasetcsv = ','.join(job.inputdata.dataset) 28 return CommonUtil.strip_to_none(datasetcsv)
29
30 -def cl_jstoolui():
31 """Build jstoolui. Only run on client.""" 32 return CommonUtil.hostname()
33
34 -def cl_nevents_requested(job):
35 """Build nevents_requested. Only run on client.""" 36 max_events = None 37 if job.application.max_events > -1: 38 max_events = job.application.max_events 39 return max_events
40
41 -def cl_output_dataset(job):
42 """Build output_dataset. Only run on client.""" 43 if not job.outputdata: return None 44 return CommonUtil.strip_to_none(job.outputdata.datasetname)
45
46 -def cl_output_se(job):
47 """Build output_se. Only run on client.""" 48 if not job.outputdata: return None 49 # job.outputdata.location can be a string or a list 50 if isinstance(job.outputdata.location, list): 51 locations = [] 52 for l in job.outputdata.location: 53 if l and l not in locations: 54 locations.append(l) 55 locationcsv = ','.join(locations) 56 else: 57 locationcsv = job.outputdata.location 58 return CommonUtil.strip_to_none(locationcsv)
59
60 -def cl_target(job):
61 """Build target. Only run on client.""" 62 if hasattr(job.backend, 'CE'): 63 targets = [] 64 if job.backend.CE: 65 targets.append('CE_%s' % job.backend.CE) 66 for site in job.backend.requirements.sites: 67 if site: 68 targets.append('SITE_%s' % site) 69 targetcsv = ','.join(targets) 70 return CommonUtil.strip_to_none(targetcsv) 71 else: 72 return CommonUtil.hostname()
73
74 -def cl_task_type(config):
75 """Build task_type. Only run on client.""" 76 return config['task_type']
77 78 79 #----- worker node meta-data builders ----- 80 #TODO: add error handling code in following methods 81
82 -def wn_load_athena_stats():
83 """Load Athena stats. Only run on worker node. 84 85 If the Athena stats.pickle file cannot be read then an empty dictionary is 86 returned. 87 """ 88 import cPickle as pickle 89 try: 90 f = open('stats.pickle','r') 91 try: 92 stats = pickle.load(f) 93 finally: 94 f.close() 95 except: 96 stats = {} 97 return stats
98