AWS Thinkbox Discussion Forums

Using Draft in Deadline Post Job Script - should it be possible?

Hi All

Is it possible to use Draft in post job script?

I’ve done successful tests using draft submissions, but whenever I try and use draft in a post job script I get a " ‘module’ object has no attribute ‘Image’" error.

Here’s the basic post job script

[code]import re
from System.IO import *
from Deadline.Scripting import *
import sys
import Draft

def main( *args ):
inFile = “C:/images/image.jpg”
# print dir(Draft) # no complaints doing this
frame = Draft.Image.ReadFromFile(inFile)
[/code]
and here’s the error report

[code]=======================================================
Log

2015-08-25 16:32:23: BEGIN - BIGBOX\Dave
2015-08-25 16:32:23: 0: Loaded plugin Maxwell (C:\DeadlineRepository7\custom\plugins\Maxwell)
2015-08-25 16:32:23: 0: Start Job timeout is disabled.
2015-08-25 16:32:23: 0: Task timeout is being ignored because this is a Post Job Script Task
2015-08-25 16:32:23: 0: Loaded job: Manual maxwell submission - Merge Job (55db2bc4bb943d2300ff1ee7)
2015-08-25 16:32:23: 0: Plugin executing post job script
2015-08-25 16:32:26: 0: Executing Post Job Script: “C:\DeadlineRepository7\custom\Spark\Post_job_Scripts\useDraftTests.py”
2015-08-25 16:32:26: 0: INFO: Executing plugin script C:\Users\Dave\AppData\Local\Thinkbox\Deadline7\slave\bigBox\plugins\55db2bc4bb943d2300ff1ee7\Maxwell.py
2015-08-25 16:32:26: 0: INFO: About: Maxwell Plugin for Deadline
2015-08-25 16:32:26: 0: INFO: The job’s environment will be merged with the current environment before rendering
2015-08-25 16:32:26: 0: INFO: Executing post job script C:\DeadlineRepository7\custom\Spark\Post_job_Scripts\useDraftTests.py
2015-08-25 16:32:27: 0: An exception occurred: Post job script “C:\DeadlineRepository7\custom\Spark\Post_job_Scripts\useDraftTests.py”: AttributeError : ‘module’ object has no attribute ‘Image’ (FranticX.Scripting.PythonNetException)
2015-08-25 16:32:27: File “none”, line 10, in main
2015-08-25 16:32:27: at Deadline.Plugins.ScriptPlugin.RenderScript(Job job, String scriptFilename, Boolean preJobScript, String& outMessage, AbortLevel& abortLevel) (Deadline.Plugins.RenderPluginException)[/code]

Hello,

Can you give us a bit better idea of what the goal is here? Also can you share the steps and settings used to get to this point? Thanks.

I was able to reproduce the issue. Currently Draft will not be able to load within the pre/post render job scripts in Deadline. I am looking into where the issue lies, but I can definitely say that Draft will be unable to run in that Python context.

Normally, you would submit an actual Deadline Draft job that is dependent on your original job. Would that work in your case? There are other hacks that we could use to get around it as well.

EDIT: What we could do is have a post-job-script that creates a new Draft Deadline job. I can give you sample code to do that if you would like.

Cool, just checking I wasn’t missing something simple.

The main aim is to do some basic resizing of still renders once they finish, which is easily done with a Deadline Draft job dependent on the render job, however it would be a tiny bit easier to integrate with our existing workflow if it could happen in a post job script so I thought I’d give it a go first. Either we’ll go for a separate Draft Job, or maybe use PIL in a post job script.

Thanks for your help.

This might be a dumb hack, but you could run Python in a fresh context from the post-process-script. Something like this (Note: I didn’t test this code specifically, but the idea should work):

### my_resize_script.py
import sys
sys.path.append( "your_deadline_repo/draft/Windows/64bit" )
import Draft

inputFilename = sys.argv[0]
#do some draft resizing and save

Then in Deadline, your post-job-script could launch that standalone script:

### my_post_process_script.py
import subprocess    
proc = subprocess.Popen( ['python', 'my_resize_script.py', 'input_image.png'] )
proc.communicate()

Kind of a weird workaround. Using PIL might be a cleaner approach. We’re looking in to solving this in a better manner.

Hmm would probably do the job… feels a bit naughty though, think I’ll go the PIL route.

If I install python modules such as PIL to the Deadline python will they always persist between Deadline upgrades, or does it depend on the scale of the update?

Well, normally when you install PIL, it will put the PIL library in the site-packages directory of Python. However, probably the easiest way to do it in Deadline would be to configure the Python settings at the repository level. Like so:

In the monitor, go to Tools > Configure Repository Options > Python Settings

From there you would add an additional search path to include wherever your PIL library resides. You could have it on a shared network location for example, then you wouldn’t have to install it on any of the slaves.

Ah yes, the additional python network path is a neat way to do it, thanks Conrad.

Privacy | Site terms | Cookie preferences