Skip to content

Commit

Permalink
Fixing "KeyError: 'nwsubmitted'" issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Foorth committed Sep 10, 2024
1 parent 6dda520 commit d46fed3
Showing 1 changed file with 31 additions and 27 deletions.
58 changes: 31 additions & 27 deletions core/dashboards/jobsummaryregion.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,34 +25,35 @@ def prepare_job_summary_region(jsr_queues_dict, jsr_sites_dict, jsr_regions_dict
:param jsr_regions_dict: dict of queue job summary
:return: list of region job summary, list of queue job summary
"""
split_by = None
if 'split_by' in kwargs and kwargs['split_by']:
split_by = kwargs['split_by']
split_by = kwargs.get('split_by', None)

jsr_queues_list = []
jsr_sites_list = []
jsr_regions_list = []

for pq, params in jsr_queues_dict.items():
for jt, resourcetypes in params['summary'].items():
for rt, summary in resourcetypes.items():
row = list()
row = []
row.append(pq)
row.append(params['pq_params']['pqtype'])
row.append(params['pq_params']['region'])
row.append(params['pq_params']['status'])
row.append(params['pq_params'].get('pqtype', 'N/A'))
row.append(params['pq_params'].get('region', 'N/A'))
row.append(params['pq_params'].get('status', 'N/A'))
row.append(jt)
row.append(rt)
row.append(params['pq_pilots']['count'])
row.append(params['pq_pilots']['count_nojob'])
row.append(summary['nwsubmitted'])
row.append(summary['nwrunning'])
row.append(summary['rcores'])
row.append(params['pq_pilots'].get('count', 0))
row.append(params['pq_pilots'].get('count_nojob', 0))
row.append(summary.get('nwsubmitted', 0))
row.append(summary.get('nwrunning', 0))
row.append(summary.get('rcores', 0))
row.append(sum([v for k, v in summary.items() if k in const.JOB_STATES]))
if summary['failed'] + summary['finished'] > 0:
row.append(round(100.0*summary['failed']/(summary['failed'] + summary['finished']), 1))

if summary.get('failed', 0) + summary.get('finished', 0) > 0:
row.append(round(100.0 * summary['failed'] / (summary['failed'] + summary['finished']), 1))
else:
row.append(0)
for js in const.JOB_STATES:
row.append(summary[js])
row.append(summary.get(js, 0))

if split_by is None:
if jt == 'all' and rt == 'all':
Expand All @@ -70,20 +71,21 @@ def prepare_job_summary_region(jsr_queues_dict, jsr_sites_dict, jsr_regions_dict
for site, jobtypes in jsr_sites_dict.items():
for jt, resourcetypes in jobtypes.items():
for rt, summary in resourcetypes.items():
row = list()
row = []
row.append(site)
row.append(jt)
row.append(rt)
row.append(summary['nwsubmitted'])
row.append(summary['nwrunning'])
row.append(summary['rcores'])
row.append(summary.get('nwsubmitted', 0))
row.append(summary.get('nwrunning', 0))
row.append(summary.get('rcores', 0))
row.append(sum([v for k, v in summary.items() if k in const.JOB_STATES]))
if summary['failed'] + summary['finished'] > 0:

if summary.get('failed', 0) + summary.get('finished', 0) > 0:
row.append(round(100.0 * summary['failed'] / (summary['failed'] + summary['finished']), 1))
else:
row.append(0)
for js in const.JOB_STATES:
row.append(summary[js])
row.append(summary.get(js, 0))

if split_by is None:
if jt == 'all' and rt == 'all':
Expand All @@ -101,20 +103,21 @@ def prepare_job_summary_region(jsr_queues_dict, jsr_sites_dict, jsr_regions_dict
for reg, jobtypes in jsr_regions_dict.items():
for jt, resourcetypes in jobtypes.items():
for rt, summary in resourcetypes.items():
row = list()
row = []
row.append(reg)
row.append(jt)
row.append(rt)
row.append(summary['nwsubmitted'])
row.append(summary['nwrunning'])
row.append(summary['rcores'])
row.append(summary.get('nwsubmitted', 0))
row.append(summary.get('nwrunning', 0))
row.append(summary.get('rcores', 0))
row.append(sum([v for k, v in summary.items() if k in const.JOB_STATES]))
if summary['failed'] + summary['finished'] > 0:

if summary.get('failed', 0) + summary.get('finished', 0) > 0:
row.append(round(100.0 * summary['failed'] / (summary['failed'] + summary['finished']), 1))
else:
row.append(0)
for js in const.JOB_STATES:
row.append(summary[js])
row.append(summary.get(js, 0))

if split_by is None:
if jt == 'all' and rt == 'all':
Expand All @@ -128,6 +131,7 @@ def prepare_job_summary_region(jsr_queues_dict, jsr_sites_dict, jsr_regions_dict
elif 'jobtype' not in split_by and 'resourcetype' in split_by:
if jt == 'all' and rt != 'all':
jsr_regions_list.append(row)

return jsr_queues_list, jsr_sites_list, jsr_regions_list


Expand Down

0 comments on commit d46fed3

Please sign in to comment.