AWS Thinkbox Discussion Forums

submitting python script as Nuke script.

Hi,
I would like to run nuke with python script instead of nuke script (equivalent of nuke -t /some/script.py paramPath1 param2). That script will generate actual nuke script to be rendered. What is the best way to do all this in event plugin?

Do I need to create plugin info, job info and ClientUtils.ExecuteCommand for “rendering” python script, detect it is done and create plugin info, job info and ClientUtils.ExecuteCommand for newly created nuke script?

Is there a function that will do Deadline repository path mapping (for translating windows mapped drives to unc…) for arbitrary string? I would like to use it to correctly translate parameters for python script (like paramPath1 above)?

I am trying to pass json string (packaged job.JobExtraInfo0 from onjobfinished event) to python script as a command line parameter. This seems to fail on illegal characters in the commandline. Maybe in json string?

What I am trying to do is what Kym suggested in 4th post: https://forums.thinkboxsoftware.com/viewtopic.php?f=11&t=14905#p67926.

Sorry for way too many newbie questions.

Thank you,

Jirka
template_Default.py.txt (2.4 KB)
NukeDailies.py.txt (14.1 KB)
CustomSanityChecks.py.txt (709 Bytes)

I would do this as a job plugin.

What version of deadline are you on?

Hi,
I am on 8, planning to switch to 9 in two weeks (possibly earlier if needed). I will read docs about job plugins, fingers crossed.
Thank you,
Jirka

Hello,

Took me a little longer than i thought to strip out our pipe specific code, but this comes from a plugin we use all the time.
I even included the icon :wink:

I have tested this with dl7.0.2 and dl 9.0.2.

Once extracted, you want to put NukePy folder in your /custom/plugins
NukePy.zip (7.94 KB)

The only caveat, is you will need to edit the param and dlint files, to add back in which nuke versions you use at your studio.
Also there is no submit gui… but that is ok, because here is the minimum info that you need to create a job via the python standalone api.

job_info = {
 'ChunkSize': '1',
 'FailureDetectionJobErrors': 5,
 'Frames': '1-1',
 'Name': 'kw test',
 'OverrideJobFailureDetection': True,
 'Plugin': 'NukePy',
 'Pool': 'nuke',
 'Priority': 50,
 'UserName': 'me'}

plugin_info = {'BatchMode': True,
 'ContinueOnError': False,
 'EnforceRenderOrder': False,
 'NukeX': False,
 'ProxyMode': False,
 'SceneFile': '//network/path/test_python_nuke.py',
 'ScriptArguments': 'hello happy world 10',
 'Verbosity': '0',
 'Version': '7.09'}

import Deadline.DeadlineConnect as Connect
Deadline = Connect.DeadlineCon(PULSESERVERNAME, 8080)

jobid = Deadline.Jobs.SubmitJob(info=job_info,
                                            plugin=plugin_info,
                                            idOnly=id_only)

print 'jobid::',jobid

The contents of my script (test_python_nuke.py) look like this:

#imports
import nuke
import sys

# print out each of the sysargs to show it works
for arg in sys.argv:
	
	print 'found a script arg:',arg

## these lines are required at the end of the script, if the job it to complete sucessfully.
# if you want it to error, you can simply have a sys.exit(1) in your script
print 'Finished running script.'
print 'READY FOR INPUT'
# needs a 0 status exit to exit cleanly...
sys.exit(0)

The script output when the job runs on the farm will then contain:

2017-05-19 16:23:29:  0: STDOUT: found a script arg: /tmp/Thinkbox/Deadline7/slave/node42/jobsData/591f539f027b94037905993f/thread0_tempeFoPi0/test_python_nuke.py
2017-05-19 16:23:29:  0: STDOUT: found a script arg: hello
2017-05-19 16:23:29:  0: STDOUT: found a script arg: happy
2017-05-19 16:23:29:  0: STDOUT: found a script arg: world
2017-05-19 16:23:29:  0: STDOUT: Finished running script.
2017-05-19 16:23:29:  0: INFO: marking the progress of the current job to 100% as its done.
2017-05-19 16:23:29:  0: STDOUT: READY FOR INPUT
2017-05-19 16:23:29:  0: INFO: Process exit code: 0
2017-05-19 16:23:29:  0: Render time for frame(s): 2.730 s
2017-05-19 16:23:29:  0: Total time for task: 6.340 s
2017-05-19 16:23:29:  0: Saving task log...

Hope this helps.
Cheers
Kym

3 Likes

Thank you so much Kym, this is tremendous help for me!

It helped me too. :smiley:

Hi Kim,

I can’t download the zip file for some reason. Can you re-upload it, please.

HI Aleksandar,

Im just checking with edwin, to see if they have the old zip file.
otherwise i make a new updated version of the zip, once i pull some of our pipeline specific changes from the code.

Cheers
Kym

Actually, it was very little work to obfuscate the code.
NukePy.zip (8.2 KB)

Enjoy.

Privacy | Site terms | Cookie preferences