submitting python script as Nuke script.

Discussion and Support of Deadline, the Render Management System
jirka
Posts: 15
Joined: Fri Jul 29, 2016 3:16 am

submitting python script as Nuke script.

Postby jirka » Thu May 18, 2017 11:05 am

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
Attachments
template_Default.py.txt
python script that should generate Nuke script
(2.4 KiB) Downloaded 3 times
NukeDailies.py.txt
event script
(14.06 KiB) Downloaded 5 times
CustomSanityChecks.py.txt
Nuke custom sanity checks
(709 Bytes) Downloaded 4 times

kwatts
Posts: 51
Joined: Tue Mar 01, 2016 10:34 am

Re: submitting python script as Nuke script.

Postby kwatts » Thu May 18, 2017 1:09 pm

I would do this as a job plugin.

What version of deadline are you on?

jirka
Posts: 15
Joined: Fri Jul 29, 2016 3:16 am

Re: submitting python script as Nuke script.

Postby jirka » Thu May 18, 2017 2:58 pm

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

kwatts
Posts: 51
Joined: Tue Mar 01, 2016 10:34 am

Re: submitting python script as Nuke script.

Postby kwatts » Fri May 19, 2017 3:46 pm

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 ;)

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

Once extracted, you want to put NukePy folder in your <repository folder>/custom/plugins
NukePy.zip
(7.94 KiB) Downloaded 7 times


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.


Code: Select all

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:

Code: Select all

#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:

Code: Select all

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

jirka
Posts: 15
Joined: Fri Jul 29, 2016 3:16 am

Re: submitting python script as Nuke script.

Postby jirka » Mon May 22, 2017 11:49 am

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


Return to “Thinkbox Software - Deadline”

Who is online

Users browsing this forum: bonsak and 1 guest