Hi!
Is there a way to access a Job associated with a girder-worker task from within that task? Specifically, I’d like to update Job’s progress message.
Cheers,
Kacper
I think if your task is a bound task, then it should have access to a couple of things:
- An instance of Girder Client, using the
girder_client
attribute of your bound task (self.girder_client
). This may or may not be authenticated already. - An instance of a JobManager, which has methods for updating progress (
self.job_manager
).
I’m a bit fuzzy on exactly what qualifies tasks for receiving both of those things, they’re attached in the Celery task-prerun signal here. @Chris_Kotfila knows a bit more about the details.
A quick code example of what @danlamanna was referring to:
from girder_worker.app import app
@app.task(bind=True)
def my_task(self, *args, **kwargs):
self.job_manager.updateProgress(message='starting', total=100, current=0)
# do stuff
Thanks a lot!