Add Django admin action to reschedule "todo" job
Please implement a Django admin action to reschedule a job that was deferred with schedule_in (or is waiting for a retry backoff) to the current time instead of waiting for the configured delay.
Hello! Is there something specific that means this needs to live in Procrastinate rather than in your code ?
Procrastinate includes the Django admin in django.contrib.admin
I believe you can unregister it and register your own subclass that has custom behaviour?
Not saying it's a bad idea or anything, but given how bare-bones the Django Admin is, I'm not sure it would make sense to include very specific features like this before other more common usecases. Also, we tried in our design to make procrastinate "hackable" (in the sense: that we try to make it so that people can do things with it that we didn't intended, and it still works), and I'm genuinely interested to better understand if customizing the Django admin ends up being an easy task or not.
I'm genuinely interested to better understand if customizing the Django admin ends up being an easy task or not
To a certain degree, yes, adding this action likely just requires a simple function with a @admin.action() decorator, I'll look into it and create a PR if this is the case.
Thanks for the PR. My initial question was: starting from the code of your PR, do you need this to be merged in Procrastinate in order to benefit from it ?
If you do the following in your own code:
@admin.action(
description="Reschedule marked jobs to run now", permissions=["reschedule"]
)
def reschedule(modeladmin, request, queryset):
...
admin.unregister(models.ProcrastinateJob)
@admin.register(models.ProcrastinateJob)
class CustomProcrastinateJobAdmin(ProcrastinateJobAdmin):
actions = ProcrastinateJobAdmin.actions + [reschedule]
Then does it work as intended for your usecase ?
Thanks, It works as intended for my use case, so this does not need to be merged into Procrastinate, but IMHO it would still be a convenient feature.
but given how bare-bones the Django Admin is, I'm not sure it would make sense to include very specific features like this before other more common usecases
Are there existing issues or specific ideas for other improvements? It should be reasonably simple to add additional actions (cancel, retry, etc), let me know if there is interest in another PR.
I think I don't envision the Django Admin interface to become really advanced (in particular, more advanced than the other interface) because it's not made for that, and it's going to play badly for anyone with customizations (Django Grapelli etc). Adding precise UI in Django admin feels like you're fighting against the machine. This is an autogenerated admin meant to follow the way your data is stored in the DB.
In contrast, I'd love the idea of a proper web interface (like celery flower for celery), independant of Django, and using modern web practices (so that would autoupdate, without constant polls, so websocket? SSE?). There's an issue for that, but I'm on mobile and it's hard to search.
Might be an opportunity to try out htmx and maybe fasthtml or htpy. This could live in a different repo under the Procrastinate umbrella.
Well, you have it, that's my current stance :) It could evolved if presented with convincing arguments.
I think I don't envision the Django Admin interface to become really advanced
Me neither, I would have suggested to implement similar functionality as the existing CLI (and ideally implement the reschedule command for the CLI to have parity).
it's going to play badly for anyone with customizations (Django Grapelli etc). Adding precise UI in Django admin feels like you're fighting against the machine. This is an autogenerated admin meant to follow the way your data is stored in the DB.
The Django admin is extensible by design and supports admin actions natively (without any template changes, etc) - if a third party package breaks this core functionality, it will affect other parts of Django as well.
Having a separate web interface would be nice, but also add complexity (deployment/monitoring/auth/etc), the Django admin is already included and provides basic job management.
--
Considering the above, would you be open to:
- a PR to implement minimal retry/cancel Django actions (similar to the shell commands)?
- an updated PR to also implement the
rescheduleaction as a shell command?
Considering the above, would you be open to:
- a PR to implement minimal retry/cancel Django actions (similar to the shell commands)?
retry/cancel definitly makes sense as a Django admin action.
- an updated PR to also implement the
rescheduleaction as a shell command?
I'm not sure I understand if this action will be useful for a lot of folks, or covers a very specific usecase. Can you tell me more on why this is important to you and how it will help other users ?
a PR to implement minimal retry/cancel Django actions (similar to the shell commands)?
Actually, unrelatedlym #1325 (about to be merged) actually does it already :)
- an updated PR to also implement the
rescheduleaction as a shell command?I'm not sure I understand if this action will be useful for a lot of folks, or covers a very specific usecase. Can you tell me more on why this is important to you and how it will help other users ?
The main use case is to "immediately" run jobs stuck in an exponential backoff or scheduled in the future via schedule_in(). Currently, those can only be rescheduled by manually updating scheduled_at in the database.