From 1bcf716f2dcc46126f22eb03cc546d10554085f3 Mon Sep 17 00:00:00 2001 From: Ammar Ammar <43293485+ammar257ammar@users.noreply.github.com> Date: Thu, 9 Jan 2025 14:16:33 +0000 Subject: [PATCH] Reset start time, end time and error message on job requeue from admin --- app/grandchallenge/components/admin.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/app/grandchallenge/components/admin.py b/app/grandchallenge/components/admin.py index dc5bc645c8..1ee3cf9a5a 100644 --- a/app/grandchallenge/components/admin.py +++ b/app/grandchallenge/components/admin.py @@ -1,5 +1,6 @@ from django.contrib import admin from django.db.transaction import on_commit +from django.utils.timezone import now from guardian.admin import GuardedModelAdmin from grandchallenge.components.models import ( @@ -93,12 +94,24 @@ def requeue_jobs(modeladmin, request, queryset): for job in queryset: job.status = ComponentJob.RETRY + job.started_at = now() + job.completed_at = None + job.error_message = "" job.attempt += 1 jobs.append(job) on_commit(job.execute) - queryset.model.objects.bulk_update(jobs, fields=["status", "attempt"]) + queryset.model.objects.bulk_update( + jobs, + fields=[ + "status", + "attempt", + "started_at", + "completed_at", + "error_message", + ], + ) @admin.action(