Skip to content

Commit

Permalink
added success message and state for interactive job on timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
shayanaijaz committed Aug 22, 2023
1 parent 6c40f35 commit 658b83d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
9 changes: 9 additions & 0 deletions server/portal/apps/webhooks/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ def validate_tapis_job(job_uuid, job_owner, disallowed_states=[]):
if job_data.status in disallowed_states:
return None

if hasattr(job_data, 'notes') and job_data.status == 'FAILED':
notes = json.loads(job_data.notes)

# checks to see if an interactive job ended with tapis timeout code of 0:0
if notes.get('isInteractive', False) and job_data.remoteResultInfo == '0:0':
job_data.status = 'FINISHED'
job_data.remoteOutcome = 'FINISHED'

return job_data


Expand Down Expand Up @@ -122,6 +130,7 @@ def post(self, request, *args, **kwargs):
job_details = validate_tapis_job(job_uuid, username, disallowed_states=non_terminal_states)
if job_details:
event_data[Notification.EXTRA]['remoteOutcome'] = job_details.remoteOutcome
event_data[Notification.EXTRA]['status'] = job_details.status

try:
logger.info('Indexing job output for job={}'.format(job_uuid))
Expand Down
19 changes: 19 additions & 0 deletions server/portal/apps/workspace/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,19 @@ def get(self, request, *args, **kwargs):

@method_decorator(login_required, name='dispatch')
class JobsView(BaseApiView):

@staticmethod
def check_job_for_timeout(job):
if hasattr(job, 'notes') and job.status == 'FAILED':
notes = json.loads(job.notes)

# checks to see if an interactive job ended with tapis timeout code of 0:0
if notes.get('isInteractive', False) and job.remoteResultInfo == '0:0':
job.status = 'FINISHED'
job.remoteOutcome = 'FINISHED'

return job

def get(self, request, operation=None):

allowed_actions = ['listing', 'search', 'select']
Expand All @@ -150,6 +163,12 @@ def get(self, request, operation=None):
op = getattr(self, operation)
data = op(tapis, request)

if (isinstance(data, list)):
for index, job in enumerate(data):
data[index] = self.check_job_for_timeout(job)
else:
data = self.check_job_for_timeout(data)

return JsonResponse(
{
'status': 200,
Expand Down

0 comments on commit 658b83d

Please sign in to comment.