AWS Thinkbox Discussion Forums

Calling DeadlineCommand from Python

So I’m working on a render submit tool for Maya. One of the issues I’m having is that Deadline’s submit script is written in Mel and I’m having a tough time working with it in my Python tool. So I’ve been considering rewriting the Deadline script in Python. But it is 10,000 lines of code long (:shock:) so I’m a bit hesitant to wade into those waters.

The big road block for me is the CallDeadlineCommand proc that is used throughout the script. Is there any documentation for this and is there a Python equivalent I can use? The main reason for a rewrite is that I need to be able to pass scene information to the submitter but I’m unsure if that is possible with Mel.

Hi ,

So it really depends on what you need to do.
At the end of the day most of the things that you need for maya can be config pulled on config per project/ and enable things to be overridden.

We only use the python standalone libs for python, see these docs:
docs.thinkboxsoftware.com/produc … Reference/

But in a nutshell:


import Deadline.DeadlineConnect as Connect
Deadline= Connect.DeadlineCon('WebServiceName', 8082)

JobInfo = {}
PluginInfo = {}

Deadline.Jobs.SubmitJob(JobInfo, PluginInfo)

Where the 2 dictionaries contain the key value pairs for what the plugin needs.

To get the best idea of all the key/ values pairs a job plugin needs open up the main maya deadline submitter :
\scripts\Submission\MayaSubmission.py

find the SubmitButtonPressed method and then look for where they start “writer.WriteLine”, these are all the key/value pairs you want.

Alternatively you can scrap them from a previously submitted job.
In the Job Properties of a selected job, goto the Submission Params, and export out the 2 files.

We pretty much use the Standalone Python class for all our farm submissions, its pretty sturdy.
For the most part an artist is already in a project shot context, and what config is needed/ job settings.

Hope this helps.

Cheers
Kym

Thanks Kym! I was just looking through the standard Maya Python submit script. It’s pretty close to the Mel version so I think I can get out of it what i need. I pretty much made our Modo submitter the same way.

I’d recommend minimizing the points of failure (Web Service) and stealing the thing Justin B wrote for the DraftWatchFolder script:
github.com/ThinkboxSoftware/Dea … hfolder.py

def CallDeadlineCommand(args):
    """
    Calls deadlinecommand with arguments as passed args with 'deadlinecommand' as the first argument
    """
    # On OSX, we look for the DEADLINE_PATH file. On other platforms, we use
    # the environment variable.
    if os.path.exists("/Users/Shared/Thinkbox/DEADLINE_PATH"):
        with open("/Users/Shared/Thinkbox/DEADLINE_PATH") as f:
            deadlineBin = f.read().strip()
        deadlineCommand = "%s/deadlinecommand" % deadlineBin
    else:
        try:
            deadlineBin = os.environ['DEADLINE_PATH']
        except KeyError:
            return ""

        if os.name == 'nt':
            deadlineCommand = "%s\\deadlinecommand.exe" % deadlineBin
        else:
            deadlineCommand = "%s/deadlinecommand" % deadlineBin

    # insert deadlineCommand as the first argument
    args.insert(0, deadlineCommand)

    # Specifying PIPE for all handles to workaround a Python bug on Windows.
    # The unused handles are then closed immediatley afterwards.
    proc = subprocess.Popen(
        args,
        cwd=deadlineBin,
        stdin=subprocess.PIPE,
        stdout=subprocess.PIPE,
        stderr=subprocess.PIPE,
        startupinfo=None)
    proc.stdin.close()
    proc.stderr.close()

    output = proc.stdout.read()
    output = output.decode("utf_8")

    return output

The web service is really stable, I just like the idea of “fewest moving parts”. This method really just needs DLC and the database to be working.

I also missed the question about docs on the Melscript equivalent function. We don’t have as many people building custom submitters atop the Melscript code due to how it’s organized (SMTD is a different beast), so you can just look at the submitter code to find it in there. For future ref, if anyone needs examples on calling DLC from a language, the most succinct scripts for this are the bootstrapper scripts in “[repo]/submission/[app]/client” because all they do is find a file and load it. AE (JavaScript), Maya (Melscript), Blender (Python), whatever the heck uses LUA are all great sources of examples.

Privacy | Site terms | Cookie preferences