AWS Thinkbox Discussion Forums

Access current task id via event callback?

Hello,
Is there a way to access the current task ID when using something like an OnSlaveRendering callback? Since it’s the workername and job passed to the event I tried something like:

    def OnSlaveRendering( self, workername, job):
        self.LogInfo("OnSlaveRendering Begin")
        workerinfo = RepositoryUtils.GetSlaveInfo(workername, True)
        taskId = workerinfo.SlaveCurrentTaskIds
        name = workerinfo.SlaveName
        self.LogInfo(f"Worker Name is: {name}")
        self.LogInfo(f"Current TaskID is: {list(taskId)}")

The worker name is returned as expected, but the SlaveCurrentTaskIds returns an empty string.

I know I’m probably missing something simple here ;).
Thanks,
-Jake

Hello @JakeS

I am not sure if the list is returned. Silly thing, could you print just the taskId? What’s the value?

It should just work fine.

A guess would be to save the settings in the DB at the end of your function definition like:
RepositoryUtils.SaveSlaveSettings(slave)

Check how it is done in this example event plugin: Deadline/Custom/events/SlaveExtraInfo/SlaveExtraInfo.py at bfc97123e259f5e8392d3d45101c52ac79a07609 · ThinkboxSoftware/Deadline · GitHub

Hi @zainali
It seems like the event is happening a bit too early in the render process for what I’m trying to accomplish. I was hoping to grab the taskId before the plugin loads. Then modify an env var with that info.
The taskId is empty when I print it.
But this:
print(workerinfo)
returns:
taskevent: worker-1 : Idle

Which makes me think that it’s evaluating before the worker picks up the task?
Thanks,
-Jake

Seems like a better place for me to do what I need is in a JobPreLoad or PluginPreLoad context. I’m able to set the env vars as necessary there.
Thanks,
-Jake

Hello!

To set the environment on the job, the jobpreload or the pluginproload would be better as it will run in the same sandbox and in the jobs environment.

Make sure if you are adding the jobs environment to the job then you save the job at the end. Here is a API call for saving the job.

Privacy | Site terms | Cookie preferences