Skip to content

Commit

Permalink
Reset start time, end time and error message on job requeue from admin
Browse files Browse the repository at this point in the history
  • Loading branch information
ammar257ammar committed Jan 9, 2025
1 parent 0679c6c commit 1bcf716
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion app/grandchallenge/components/admin.py
Original file line number Diff line number Diff line change
@@ -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 (
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 1bcf716

Please sign in to comment.