AWS Thinkbox Discussion Forums

Pass current task id in nuke ScriptFilename

Their are multiple tasks for a job in deadline monitor. For every task a nuke script is run. To this nuke script how do I pass current task id ?

connect.Tasks.GetJobTask(job_id, current_task_id) returns a dict which includes frame range for a given task. ( this is what i require )

Searching on google, I find this link where it is possible to get task id like so

Deadline.Jobs.Task.TaskId

Is this the correct way. I am clueless.

from Deadline.Scripting import *

If this not the way then back to the first point. How else can i get to pass task id in context to the nuke script

I just answered this in another post
When the plugin runs, it knows the task. You can obtain it from the plugin using self.GetCurrentTaskId

This is the right direction. How to get the self. In my plugins script i can only see this much
which is in repo10/api/python/Deadline. Is there another api ?

from future import absolute_import

from .ConnectionProperty import ConnectionProperty

from ConnectionProperty import ConnectionProperty

class Plugins:
“”"
Class used by DeadlineCon to send Plugin requests.
Stores the address of the Web Service for use in sending requests.
“”"
def init(self, connectionProperties):
self.connectionProperties = connectionProperties

def GetPluginNames(self):
    """ Gets the Plugin names.
        Returns: The list of Plugin names.
    """
    return self.connectionProperties.__get__("/api/plugins")

def GetEventPluginNames(self):
    """ Gets the event Plugin names.
        Returns: The list of event Plugin names.
    """
    return self.connectionProperties.__get__("/api/plugins?EventNames=true")

Oh wait you are using the standalone API, which is completely different from the Deadline Scripting API.
The standalone api is useful to communicate with Deadline, such as to list jobs, modify properties, etc.
But the actual plugins are in the scripting api. You place them in <repository>/custom/plugins/YourCustomPlguin and they become available as plugins.
You need to read up on the docs, there are nice introductions in the Deadline Manual.

yourcustomplugin is what I need to build up. Their is nothing initially. Correct ?
Where as self.GetCurrentTaskId is in some script/class. Where can i download or find reference to it ?

A moment. If i do pip install on the deadline-stubs-*.tar.gz as the document says I will be able to install it. Got it. Thank you

@mois.moshev. I installed it on my machine found Scripting folder to be empty. How will i run self.GetCurrentTaskId ? Plugins is also empty

You will need to write the entire plugin. You can start by coying \YourRepository\plugins\Nuke to \YourRepository\custom\plugins\Nuke and start by modifying the original nuke plugin. Note that if you have a custom plugin with the same as one that already ships with deadline the custom one should take precedence.

Also note that, depending on what you are trying to do in you script it might be a lot more convenient to work with a event plugin then modifying the entire nuke plugin.

Sure, I could copy from location as seen in the image above to \yourrepository\custom\plugins\Nuke

Question still is, do i get self.GetCurrentTaskId. What class/script is it a part of that I can derive as a subclass. This is an inbuilt method.

It’s a member of the DeadlinePlugin class that the NukePlugin inherits from.

So where can i find it such that when i do

import DeadlinePlugin

it will return something

Sorry, my installation does not show me anything substantive that is why i need clarification ?

I’m not sure where you are trying to use this but I think you’re on the wrong track here.
You are not really supposed to this outside of the actual plugin definition as Deadline will handle instancing the plugin internally and you’ll only be able to get any data out of it if you get a hold of instance that then lives inside of deadline anyways.

So what you are saying is,

Bring the nuke script that resides outside of deadline\custom… inside the system. And from within the script do a

from Deadline.Plugins import DeadlinePlugin

create a class based on this. and use the GetCurrentTaskId and it should work ?

Actual DeadlinePlugin is concealed.

I would not try to get any deadline classes into you script. If you need to access anything in deadline fron an external script you should ony use the standalone API. Getting the task that caused this very script to run through the API is not super trivial though and IMHO a somewhat backward approach.
It would be more straightforward if plugin at execution would pass the needed info to your script directy. A possible approach to this would be what I suggested here.

I did not get it. According to image its a python script that does operation on a nuke script.

self.WritePython( “with open(”{}") as f: exec(compile(f.read(), “{}”, ‘exec’), globals(), locals()))".format(scriptFileName, scriptFileName) )

In this example what is writePython.

As @mois.moshev suggested, I will go through this document

After implementation, I will update this ticket so it completes the entire conversation and helps anyone.

Thank you @Kevin_N and @mois.moshev , chatting here helped a lot

Sorry for creating two threads.

WritePython is ja function defined elsewhere in the plugin. All it basically does is writing the command generated in the line you posted to the StdIn of the managed process. You shouldn’t really need to care what it does as long as you use this line tp build a poper command.

Anything else about this is a too nuke specific for me to actually know how it works.

This link on the forum is in the line of fulfilling the requirement. I got to try this approach.

Thank you @Kevin_N and @mois.moshev as always

1 Like
Privacy | Site terms | Cookie preferences