AWS Thinkbox Discussion Forums

getdeadlinejobproperties

Hello,

I’ve hacked the below together from the cookbook and forum but I’m having a problem with the function getdeadlinejobproperties(). I note that there are no *.job files in the deadline job directory (or any job directory). Specifically I want to get a list of output directories and output filenames for the 3DsMax job that the draft job is launched from (currently using the right-click scripts submission technique).

Also, I would like to get the repository directory dynamically rather than hard coding it into my script but I haven’t worked out how. Any ideas?

Thanks in advance,

Josh.

import Draft
import sys	
import os
from DraftParamParser import *	

deadlineRepository = r"\\server\projects\DeadlineRepository6" #Deadline repository, why can't I get the property dynamically?

# The argument name/types we're expecting from the command line arguments or Deadline.
expectedTypes = dict()
expectedTypes['deadlineJobID'] = '<string>'

# Parse the command line arguments.
params = ParseCommandLine( expectedTypes, sys.argv )	# params now contains a dictionary of the parameters initialized to values from the command line arguments.
deadlineJobID = params["deadlineJobID"] #contains the original Job's ID

jobProps = GetDeadlineJobProperties( deadlineRepository, deadlineJobID )

returns;

0: Task timeout is disabled.
0: Loaded job: test2014 [DRAFT] (54b3f9cbc4afc90fe0a45e4b)
0: INFO: Executing plugin script C:\Users\joshua\AppData\Local\Thinkbox\Deadline6\slave\ODIN06\plugins\54b3f9cbc4afc90fe0a45e4b\Draft.py
0: INFO: Found Draft python module at: ‘C:\Users\joshua\AppData\Local\Thinkbox\Deadline6\slave\ODIN06\Draft\Draft.pyd’
0: INFO: About: Draft Plugin for Deadline
0: INFO: The current environment will be used for rendering
0: Plugin rendering frame(s): 1
0: INFO: Draft job starting…
0: INFO: Stdout Handling Enabled: True
0: INFO: Popup Handling Enabled: False
0: INFO: Using Process Tree: True
0: INFO: Hiding DOS Window: True
0: INFO: Creating New Console: False
0: INFO: Looking for bundled python at: ‘C:\Program Files\Thinkbox\Deadline6\bin\dpython.exe’
0: INFO: Executable: “C:\Program Files\Thinkbox\Deadline6\bin\dpython.exe”
0: INFO: Argument: -u “P:\THESYSTEM\02-CreateLayeredEXR\Draft\EXRlayering-A05.py” username=“joshua” entity=“test2014 " version=”" inFile="\horus\projects\TEST\R3\deadline_test-####.jpg" outFolder="\horus\projects\TEST\R3\Draft" outFile="\horus\projects\TEST\R3\Draft" startFrame=1 endFrame=1 frameList=“1” deadlineJobID=54b3b4bac4afc90fe0a45e30 deadlineRepository="\server\projects\DeadlineRepository6" taskStartFrame=1 taskEndFrame=1
0: INFO: Startup Directory: “C:\Users\joshua\AppData\Local\Thinkbox\Deadline6\slave\ODIN06\Draft”
0: INFO: Process Priority: BelowNormal
0: INFO: Process Affinity: default
0: INFO: Process is now running
0: STDOUT: Checking for license at @ISIS
0: STDOUT: Draft 1.1.1.55749
0: STDOUT: Command line args:
0: STDOUT: username=joshua
0: STDOUT: entity=test2014
0: STDOUT: version=
0: STDOUT: inFile=\server\projects\TEST\R3\deadline_test-####.jpg
0: STDOUT: outFolder=\server\projects\TEST\R3\Draft
0: STDOUT: outFile=\server\projects\TEST\R3\Draft
0: STDOUT: startFrame=1
0: STDOUT: endFrame=1
0: STDOUT: frameList=1
0: STDOUT: deadlineJobID=54b3b4bac4afc90fe0a45e30
0: STDOUT: deadlineRepository=\server\projects\DeadlineRepository6
0: STDOUT: taskStartFrame=1
0: STDOUT: taskEndFrame=1
0: STDOUT: ERROR: Could not find the Job File at path: ‘\server\projects\DeadlineRepository6\jobs\54b3b4bac4afc90fe0a45e30\54b3b4bac4afc90fe0a45e30.job’.
0: INFO: Process exit code: 0
0: INFO: Draft job complete!

Yeah, at the moment the cookbook example on getting deadline job properties is out of date. That was the method used for Deadline 5. I’ve updated the sample scripts in the Deadline repository directory draft/Samples/Encode, but the cookbook example also needs updating. (I’m planning on updating the cookbook example when I move them over to the new documentation site, but that hasn’t happened yet, sorry.) Look at the simple_slate_h264* examples for the new method of getting Deadline job properties. You can find additional information in the deadline documentation at:
http://docs.thinkboxsoftware.com/products/deadline/6.2.1/1_User%20Manual/manual/scriptingpythonapi.html (Deadline 6.2)
http://docs.thinkboxsoftware.com/products/deadline/7.0/1_User%20Manual/manual/standalone-python.html?highlight=python (Deadline 7)

Note: The sample scripts were updated in Draft 1.2.3. I’ll attach them here as well.

Cheers,
Andrea
simple_slate_h264_with_proxy.zip (4.31 KB)

In terms of getting the current repository root that a Deadline install is pointing to, you can call DeadlineCommand with the “GetRepositoryRoot” command. This is how we do it for all of our integrated submitters, too.

If DeadlineCommand is in the path, it’s just a matter of parsing the result of this command:

deadlinecommand GetRepositoryRoot

Assuming your Deadline client binaries aren’t in the machine’s PATH environment, though (we stopped putting it there by default in 6, I believe), you might need to check the DEADLINE_PATH environment variable to see where it’s installed (or hardcode it, I suppose). This is, perhaps infuriatingly, slightly different on OSX; because of the many different, diverging ways of setting environment variables, we just set it in a file. All that being said, here’s a code snippet of how to handle all that in Python (taken from our Nuke submitter):

[code]
import os, sys, subprocess, traceback
def GetRepositoryRoot():
# 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 = deadlineBin + “/deadlinecommand”
else:
try:
deadlineBin = os.environ[‘DEADLINE_PATH’]
except KeyError:
return “”

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

startupinfo = None
if os.name == 'nt' and hasattr( subprocess, 'STARTF_USESHOWWINDOW' ): #not all python versions have this
    startupinfo = subprocess.STARTUPINFO()
    startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW

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

root = proc.stdout.read()
root = root.replace("\n","").replace("\r","")
return root[/code]

Hope this helps!

-Jon

Hi Jon,

Thanks for your input! Currently I am having success using the following line to get the repository root;

#Path to the Deadline Repository root deadlineRepo = params['deadlineRepository']

I’m going to have a look at the Nuke submitter for further ideas.

J.

Hi Andrea,

Thank you also for your input, this has been a great help. Having look over what you have sent me I’m still having trouble getting the job properties for Deadline. Currently the error I have is with DeadlineConnect;

2015-01-14 11:44:00: 0: STDOUT: import Deadline.DeadlineConnect as Connect 2015-01-14 11:44:00: 0: STDOUT: ImportError: No module named Deadline.DeadlineConnect

Kind regards,

Josh.

Oh… I forgot to point out that there’s setup steps to use the standalone API… you can find them at: http://docs.thinkboxsoftware.com/products/deadline/6.2.1/1_User%20Manual/manual/scriptingpythonapi.html

(I managed to read right past them myself when I was rewriting the sample scripts, and Jon reminded me about them this morning.)

Cheers,
Andrea

Hi Andrea,

Thanks for your persistence. I have actually already installed Python locally and copied the Deadline folder from \DeadlineRepository7\api\python to C:\Python27\Lib\site-packages is this correct? Do I need to do this on all slaves I want my Draft scripts to work on? How do I test that this is successful?

I didn’t have the Pulse web service running before but now I do but I still can’t get this to work.

With thanks,

Josh.

I think I’ve stumbled into the answer here, Deadline is looking for Python in;

C:\Program Files\Thinkbox\Deadline7\bin

so I have copied the Deadline folder into the site-pakages folder here and now we’re moving.

Thanks,

J.

I’m glad it’s working now. I suspect you’ll need to do it for each of the slaves you want to run Draft on, but I’ll double-check with Jon.

Hi Andrea,

I am now having trouble querying the output filenames and directories as you would see in the submission parameters for the parent job when submitting based on a previous job. Can you give me some pointers?

Also, is there a way to tell if a script has been submitted using either the right click on a job menu or from the “submit” drop down menu?

Kind regards,

Josh.

Hey Josh,

We don’t really have an overt way of telling a ‘right-click’ submission vs. a ‘Submit Menu’ submission, but you should be able to tell from the arguments passed from the Script. The right-click submitter would, for example, pass the ID of the original (right-clicked) job as “deadlineJobId=”, whereas that argument just wouldn’t be there if submitted from the standalone submitter.

Now, in order to get the output files/directories from the original job through the Standalone Python/RESTful API, it’d be something like this:

import Draft
import DraftParamParser

import Deadline.DeadlineConnect as Connect

#parse all the params into a dictionary
params = DraftParamParser.ParseCommandLine_TypeAgnostic( sys.argv )

#connect to the Deadline Pulse Web Server
connObj = Connect.DeadlineCon( 'localhost', 8181 )
connObj.SetAuthenticationCredentials( 'jon', '' ) # auth credentials

if 'deadlineJobId' in params:
    parentJobID = params['deadlineJobId']
    job = connObj.Jobs.GetJob( parentJobID )

    outputDirectories = job['OutDir'] #list of directories
    outputFilenames = job['OutFile'] #list of Output Filenames.

Hope this helps!

-Jon

Hi Jon,

This is a great help, thank you!

Josh.

Hi Jon,

Things are progressing well but I have a new problem. When I submit a Draft job based on another job then I can get the params no problem, but when I submit a Draft job using the Deadline monitor Submit drop down menu then the parameter “inFile” is not found;
Something strange seems to be happening, note the two lines I’ve made bold the inFile seems to be part of the
Job properties;

ScriptArg8=inFile=“P:/TEST/R5/0000-MyClient-MyProject-Camera-V001-.0001.exr”

Job report;

2015-01-22 14:21:20: 0: STDOUT: Checking for a license…
2015-01-22 14:21:20: 0: STDOUT: Draft 1.2.3.57201
2015-01-22 14:21:20: 0: STDOUT: Command line args:
2015-01-22 14:21:20: 0: STDOUT: username=joshua
2015-01-22 14:21:20: 0: STDOUT: entity=0000-MyClient-MyProject-Camera-V001-image_submit
2015-01-22 14:21:20: 0: STDOUT: version=
2015-01-22 14:21:20: 0: STDOUT: frameList=1
2015-01-22 14:21:20: 0: STDOUT: startFrame=1
2015-01-22 14:21:20: 0: STDOUT: endFrame=1
2015-01-22 14:21:20: 0: STDOUT: outFolder=P:\TEST\R5\Draft
2015-01-22 14:21:20: 0: STDOUT: outFile=P:\TEST\R5\Draft" inFile=P:\TEST\R5\0000-MyClient-MyProject-Camera-V001-.0001.exr deadlineRepository=P:\DeadlineRepository7 taskStartFrame=1 taskEndFrame=1
2015-01-22 14:21:20: 0: STDOUT: Error: ERROR: Expected parameter ‘inFile’ was not found.
2015-01-22 14:21:20: 0: STDOUT: inFilePattern:
2015-01-22 14:21:20: 0: STDOUT: Traceback (most recent call last):
2015-01-22 14:21:20: 0: STDOUT: File “P:\THESYSTEM\02-CreateLayeredEXR\Draft\MINMUD-title-A01.py”, line 40, in
2015-01-22 14:21:20: 0: STDOUT: print “inFilePattern:”, inFilePattern
2015-01-22 14:21:20: 0: STDOUT: NameError: name ‘inFilePattern’ is not defined
2015-01-22 14:21:21: 0: INFO: Process exit code: 1

In fact what is being sent from the submission script seems to have a problem

Params: {
‘username’: ‘joshua’, ‘endFrame’: ‘1’,
‘entity’: ‘0000-MyClient-MyProject-Camera-V001-image_submit’,
‘outFile’: ‘P:\TEST\R5\Draft" inFile=P:\TEST\R5\0000-MyClient-MyProject-Camera-V001-.0001.exr deadlineRepository=P:\DeadlineRepository7 taskStartFrame=1 taskEndFrame=1’,
‘version’: ‘’, ‘outFolder’: ‘P:\TEST\R5\Draft’, ‘startFrame’: ‘1’, ‘frameList’: ‘1’
}

Any ideas?

Thanks,

J.

There seems to be a quote character at the end of your outFile value. Did you by any chance add that by accident? Alternately, does the outfile value end in a backslash ()?

Hi Andrea,

I don’t specify an output file, the Draft submission defaults to an MOV extension and I remove the entire filename from this text field as I will create the output filename from the input filename. Maybe this is causing the problem. I will play around a little and report back.

J.

When you removed the filename, did you also remove the last directory backslash as well? On some versions of the submitter, having that last backslash would effectively “escape” the closing quotation mark, which messes up things. What version of Deadline are you using? (I believe it was fixed on later versions…)

Hi again Andrea,

The Output Folder name is “Draft” (automatically filled in),
The Output File name is completely empty.

Deadline 7

J.

Okay… one more test… put some dummy text in the Output File name field, and just ignore that data in your script. Does it work then?

Yes this works.

J.

Thanks! I’ll let Jon know that there’s an issue when that field is left blank.

Privacy | Site terms | Cookie preferences