Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

Commit

Permalink
Cleaned State information and replaced uid in 'CANCELLED by' with
Browse files Browse the repository at this point in the history
either user or operator.
  • Loading branch information
FokkeDijkstra committed May 17, 2024
1 parent 5b20595 commit 242718f
Showing 1 changed file with 29 additions and 8 deletions.
37 changes: 29 additions & 8 deletions jobinfo
Original file line number Diff line number Diff line change
Expand Up @@ -150,21 +150,42 @@ def get_max_int(jobstate, name, fieldname):
print('Returning: {}'.format(value))
return value

def get_append(jobstate, name, fieldname):
def get_state(jobstate, name, fieldname):
"""Append unique values from fieldname from the list of jobsteps"""
if debug:
print('** Debugging output for {} using {} appending values'.format(name, fieldname))
output = ''
states = []
for line in jobstate:
item = line[fieldname]
if debug:
print('{}: {}'.format(line['JobID'], item))
if item != '':
if output == '':
output = item
else:
output = ','.join(sorted(set(output.split(',') + [item])))
item = line[fieldname]
if item not in states:
states.append(item)
if len(states) > 1:
# Completed should be the only value, if not remove it
if 'COMPLETED' in states:
states.remove('COMPLETED')
# Remove CANCELLED when TIMEOUT is present
if 'CANCELLED' in states and 'TIMEOUT' in states:
states.remove('CANCELLED')
if len(states) > 0:
# Find and adjust 'CANCELLED by' and remove 'CANCELLED' if it is also present
found_cancelled_by = False
for index in range(len(states)):
if 'CANCELLED by' in states[index]:
found_cancelled_by = True
# Replace uid by 'user' or 'operator'
uid = int(states[index][12:])
if uid > 10000000:
states[index] = 'CANCELLED by user'
else:
states[index] = 'CANCELLED by operator'
if found_cancelled_by and 'CANCELLED' in states:
states.remove('CANCELLED')
output = ','.join(states)
else:
output = missing_data
if debug:
print('Returning: {}'.format(output))
return output
Expand Down Expand Up @@ -359,7 +380,7 @@ job_data = [
[ 'NNodes', get_max_int, 'NNodes', False ],
[ 'NCPUs', get_max_int, 'NCPUs', False ],
[ 'NTasks', get_max_int, 'NTasks', True ],
[ 'State', get_append, 'State', False ],
[ 'State', get_state, 'State', False ],
[ 'Submit', get_first, 'Submit', False ],
[ 'Start', get_min_date, 'Start', False ],
[ 'End', get_max_date, 'End', False ],
Expand Down

0 comments on commit 242718f

Please sign in to comment.