Add `args` and `kwargs` to job context for `on_job_start`/`on_job_end` hooks
frankie567 opened this issue · 1 comments
frankie567 commented
on_job_start
/on_job_end
hooks are really useful for adding logs, setting up monitoring tasks, etc.
Currently, those hooks are passed a job context like this:
It would be really interesting to also have the args
and kwargs
so we could log them or perhaps triggering specific behavior when detecting certain arguments.
This could look like this:
job_ctx = {
'job_id': job_id,
'job_try': job_try,
'enqueue_time': ms_to_datetime(enqueue_time_ms),
'score': score,
'args': args,
'kwargs': kwargs,
}
If that makes sense, I would happily open a PR with the required changes.
KShah707 commented
As a manual workaround for now you can of course use
job = Job(ctx["job_id"], ctx["redis"])
job_def: JobDef = await job.info()
print(job_def["args"])
print(job_def["kwargs"])