Beispiel #1
0
 def parse_record(self, record):
     '''parse an individual job record'''
     job = None
     resource_specs = {}
     resources_used = {}
     state = None
     host_str = None
     for line in record.split('\n'):
         line = line.strip()
         if state == 'exec_host':
             if not line.startswith('exec_port'):
                 host_str += line
                 continue
             else:
                 hosts = {}
                 for host in host_str.split('+'):
                     node, core = host.split('/')
                     if node not in hosts:
                         hosts[node] = []
                     hosts[node].append(core)
                 job.exec_host = hosts
                 state = None
                 host_str = None
         if line.startswith('Job Id:'):
             _, job_id = line.split(':', 1)
             job = PbsJob(self._config, job_id.strip())
         elif line.startswith('Job_Name ='):
             job.name = self._get_value(line)
         elif line.startswith('euser ='******'job_state = '):
             job.state = self._get_value(line)
         elif line.startswith('queue ='):
             job.queue = self._get_value(line)
         elif line.startswith('Account_Name ='):
             job.project = self._get_value(line)
         elif line.startswith('resources_used.walltime ='):
             walltime = self._get_value(line)
             resources_used['walltime'] = walltime2seconds(walltime)
         elif line.startswith('Resource_List.walltime ='):
             walltime = self._get_value(line)
             resource_specs['walltime'] = walltime2seconds(walltime)
         elif line.startswith('Resource_List.nodect = '):
             nodect = int(self._get_value(line))
             resource_specs['nodect'] = nodect
         elif line.startswith('exec_host ='):
             host_strs = self._get_value(line).split('+')
             exec_host = dict()
             for host_str in host_strs:
                 if '/' in host_str:
                     host, cores = host_str.split('/')
                     exec_host[host] = cores
                 else:
                     exec_host[host_str] = None
             job.exec_host = exec_host
         elif line.startswith('Resource_List.partition ='):
             job.partition = self._get_value(line)
     job.add_resource_specs(resource_specs)
     job.add_resources_used(resources_used)
     return job
Beispiel #2
0
 def parse_record(self, record):
     '''parse an individual job record'''
     job = None
     resource_specs = {}
     resources_used = {}
     state = None
     host_str = None
     for line in record.split('\n'):
         line = line.strip()
         if state == 'exec_host':
             if not line.startswith('exec_port'):
                 host_str += line
                 continue
             else:
                 hosts = {}
                 for host in host_str.split('+'):
                     node, core = host.split('/')
                     if node not in hosts:
                         hosts[node] = []
                     hosts[node].append(core)
                 job.exec_host = hosts
                 state = None
                 host_str = None
         if line.startswith('Job Id:'):
             _, job_id = line.split(':', 1)
             job = PbsJob(self._config, job_id.strip())
         elif line.startswith('Job_Name ='):
             job.name = self._get_value(line)
         elif line.startswith('euser ='******'job_state = '):
             job.state = self._get_value(line)
         elif line.startswith('queue ='):
             job.queue = self._get_value(line)
         elif line.startswith('Account_Name ='):
             job.project = self._get_value(line)
         elif line.startswith('resources_used.walltime ='):
             walltime = self._get_value(line)
             resources_used['walltime'] = walltime2seconds(walltime)
         elif line.startswith('Resource_List.walltime ='):
             walltime = self._get_value(line)
             resource_specs['walltime'] = walltime2seconds(walltime)
         elif line.startswith('Resource_List.nodect = '):
             nodect = int(self._get_value(line))
             resource_specs['nodect'] = nodect
         elif line.startswith('exec_host ='):
             host_strs = self._get_value(line) .split('+')
             exec_host = dict()
             for host_str in host_strs:
                 if '/' in host_str:
                     host, cores = host_str.split('/')
                     exec_host[host] = cores
                 else:
                     exec_host[host_str] = None
             job.exec_host = exec_host
         elif line.startswith('Resource_List.partition ='):
             job.partition = self._get_value(line)
     job.add_resource_specs(resource_specs)
     job.add_resources_used(resources_used)
     return job
Beispiel #3
0
 def check_time_res(self, val, resource_spec):
     '''check a time resource'''
     attr_name, attr_value = val.split('=')
     try:
         seconds = walltime2seconds(attr_value)
         resource_spec[attr_name] = seconds
     except InvalidWalltimeError:
         self.reg_event('invalid_{0}_format'.format(attr_name),
                        {'time': attr_value})
 def check_time_res(self, val, resource_spec):
     '''check a time resource'''
     attr_name, attr_value = val.split('=')
     try:
         seconds = walltime2seconds(attr_value)
         resource_spec[attr_name] = seconds
     except InvalidWalltimeError:
         self.reg_event('invalid_{0}_format'.format(attr_name),
                        {'time': attr_value})
Beispiel #5
0
 def _format_info(info):
     '''format values in info dictionary'''
     for key in PbsJobEvent._int_keys:
         if key in info:
             info[key] = int(info[key])
     for key in PbsJobEvent._time_keys:
         if key in info:
             info[key] = walltime2seconds(info[key])
     for key in PbsJobEvent._mem_keys:
         if key in info:
             info[key] = size2bytes(info[key])
     key = 'exec_host'
     if key in info:
         exec_host = dict()
         for exec_host_str in info[key].split('+'):
             host, cores = exec_host_str.split('/')
             exec_host[host] = cores
         info[key] = exec_host
Beispiel #6
0
 def _format_info(info):
     '''format values in info dictionary'''
     for key in PbsJobEvent._int_keys:
         if key in info:
             info[key] = int(info[key])
     for key in PbsJobEvent._time_keys:
         if key in info:
             info[key] = walltime2seconds(info[key])
     for key in PbsJobEvent._mem_keys:
         if key in info:
             info[key] = size2bytes(info[key])
     key = 'exec_host'
     if key in info:
         exec_host = dict()
         for exec_host_str in info[key].split('+'):
             host, cores = exec_host_str.split('/')
             exec_host[host] = cores
         info[key] = exec_host