Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete and retry tasks through Django Admin #92

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mgax
Copy link
Contributor

@mgax mgax commented Aug 1, 2024

I found it super useful to be able to delete and to reschedule tasks through the Django Admin.


Update – this PR now adds two admin actions:

  • Reenqueue: change the status of the selected tasks to NEW, so they will be executed again.
  • Duplicate: clone the selected tasks, leaving the old ones unchanged, and the new ones as NEW, with no result or started/finished timestamps.

from .models import DBTaskResult


def retry(modeladmin: "DBTaskResultAdmin", request, queryset):
rows = queryset.update(status=ResultStatus.NEW)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RealOrangeOne I'm not sure if it's a good idea to reuse DBTaskResult rows; maybe we should be creating new rows instead. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For my use case (processing a bunch of documents), I find it useful to be able to retry failed tasks, until there are none left, fixing errors in the process. If we were to create new rows, then I'd have to stop the queue, retry the tasks, delete the old tasks, and then restart the queue.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Perhaps "Reenqueue" which updates the task, and a "Duplicate" which duplicates.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then we shall have both! I've updated the PR as you suggest, with a small test to make sure that duplicate tasks actually work.

@mgax mgax force-pushed the feature/admin-delete-and-retry branch from faae1df to a608fc1 Compare August 2, 2024 15:42
@mgax mgax requested a review from RealOrangeOne August 2, 2024 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants