From: Craig Allison <craig@(email surpressed)>
Subject: Nuke Submit...
   Date: Wed, 10 Nov 2010 12:34:53 -0500
Msg# 1971
View Complete Thread (7 articles) | All Threads
Last Next
Has anyone done a Nuke submit script that auto pulls in all the basic
requirements for rendering from the current open script (i.e. Script
path, frames etc.)?

Looking to get our current submit a little more elegant so any tips
gratefully received!

Cheers

Craig

Craig Allison
Digital Systems & Data Manager
The Senate Visual Effects

   From: Greg Ercolano <erco@(email surpressed)>
Subject: Re: Nuke Submit...
   Date: Wed, 10 Nov 2010 15:31:25 -0500
Msg# 1972
View Complete Thread (7 articles) | All Threads
Last Next
Craig Allison wrote:
> [posted to rush.general]
> 
> Has anyone done a Nuke submit script that auto pulls in all the basic =
> requirements for rendering from the current open script (i.e. Script =
> path, frames etc.)?
> 
> Looking to get our current submit a little more elegant so any tips =
> gratefully received!

Hi Craig,

	If no one else chimes in, I'll see if I can make one of these for ya.

	If you have a semi-recent version of rush, note that all the submit
	scripts take optional '-field' arguments, which allows you to pre-load
	the submit forms with data from the command line, eg:

		perl //somewhere/rushscripts/submit-maya.pl \
			-field "JobTitle:" "MY_TEST" \
			-field "Frames:" "2-222"

	..which will open the submit-maya form with the "Job Title" field
	preset to "MY_TEST", and the "Frames:" field set to "2-222".

	This is handy for opening up the submit form from inside nuke
	with e.g. the nuke scene file and frame range preset to what's
	currently loaded in nuke.

	Many folks have privately sent me code snippets on how to add
	Rush submit forms to nuke over the years, but some might be dated.

	I prefer to teach people to fish instead of giving them one ;)
	(I'll give you the fish in a separate followup to this thread)

SOME NOTES ON HOW TO ADD MENU ITEMS TO NUKE
-------------------------------------------

	Anyone wanting to create custom nuke menus should check this video:
	http://www.thefoundry.co.uk/articles/2009/12/01/77/nuke-python-essentials-adding-menu-items/

	Apologies if that link eventually goes stale. That video is also
	on "The Foundry Channel" on YouTube as: http://www.youtube.com/v/3-gR3ZpWTdw

TLDR; HOW TO MAKE A MENU ITEM IN NUKE
-------------------------------------
	For our purposes, long story short, the following code will create
	a submenu called "Rush" with an item called "Hello" which, when clicked,
	will open a "hello world!" dialog.. a good starting point.

		nukebar = nuke.menu("Nuke")
		rushsubmenu = nukebar.addMenu("Rush")
		rushsubmenu.addCommand('Hello', 'nuke.message("hello world!")')

	When you run that in the Nuke script editor, a "Rush" menu will appear
	in nuke's menubar.

A SLIGHTLY MORE USEFUL EXAMPLE
------------------------------
	The above commands show how to open a simple dialog, but what if we
	want to run our own python function that has more complexity?

	The second argument of the above addCommand() is a python command,
        so you can invoke the name of your own python function instead.

	So instead of calling 'nuke.message()', we can define our own function, 
        RushHello(), and set it up to be run when the item is clicked, e.g.:

		# DEFINE A FUNCTION CALLED "RushHello()"
		def RushHello():
		    nuke.message("hello world!")

		# MAKE A MENU ITEM THAT CALLS THAT FUNCTION
		nukebar = nuke.menu("Nuke")
		rushsubmenu = nukebar.addMenu("Rush")
		rushsubmenu.addCommand('Hello', 'RushHello()')

	Functionally this is equivalent to the previous example, but here we
	can go crazy with the contents of the RushHello() python function,
	adding code to do lots more stuff than just show a dialog.

	I'll follow up later with how to make nuke fire up the Rush
	submit form with data fields preset to the Frames and Nuke Script.

HOW TO MAKE THIS "PERMANENT" IN NUKE
------------------------------------

	You can add these commands to the global menu.py in the nuke 
        "plugins" directory, so whenever you run nuke the "Rush" menu
        will be there automatically, eg:

		  LINUX: /usr/local/Nuke6.1v1-32/plugins/menu.py
		WINDOWS: c:/program files/nuke6.1v1/plugins/menu.py

	For more info, see nuke's own docs on customizing nuke for other ways
	to approach defining your own plugins.

STEP BY STEP DETAILS ON HOW TO DO THE ABOVE
-------------------------------------------

	Here's some precise instructions for how to do the above tests
        for those not familiar with scripting in nuke. In the following case
        I'm using Nuke 6.1:

		1) Run 'nuke'

		2) Right-click on the 'Viewer1' tab, and choose "Script Editor"

		3) In the script editor window, you can type python commands.
		   Just as a test, try typing:

			nuke.message("hello world!")

		   ..and hit CTRL-ENTER to run it. A dialog should pop up
		   saying 'hello world!' and you can click OK to close it.

		   Note: Similar to Maya's script editor, hitting just 'ENTER'
		   gives you a new line without running the command. This way
		   you can compose large multiline code snippets. When you want
		   to run everything you've typed, hit CTRL-ENTER.

		4) Now you should be able to paste the above commands to create
		   a "Rush" menu with the "Hello" submenu item, eg:

		        nukebar = nuke.menu("Nuke")
		        rushsubmenu = nukebar.addMenu("Rush")
		        rushsubmenu.addCommand('Hello', 'nuke.message("hello world!")')

                   Be sure to hit CTRL-ENTER after pasting to run it.

[EDITED FOR CLARITY - erco 11/10/10]
-- 
Greg Ercolano, erco@(email surpressed)
Seriss Corporation
Rush Render Queue, http://seriss.com/rush/
Tel: (Tel# suppressed)ext.23
Fax: (Tel# suppressed)
Cel: (Tel# suppressed)

   From: Greg Ercolano <erco@(email surpressed)>
Subject: Re: Nuke Submit...
   Date: Wed, 10 Nov 2010 17:13:06 -0800
Msg# 1973
View Complete Thread (7 articles) | All Threads
Last Next
> Craig Allison wrote:
>> Has anyone done a Nuke submit script that auto pulls in all the basic =
>> requirements for rendering from the current open script (i.e. Script =
>> path, frames etc.)?
>>
>> Looking to get our current submit a little more elegant so any tips =
>> gratefully received!

	Here's something simple that adds a Rush/Submit item
	to the nuke menu bar:

---- snip
def RushSubmit():
    nukescript = nuke.Root().name()
    sfrm = nuke.Root().firstFrame()
    efrm = nuke.Root().lastFrame()
    cmd = ( "perl //yourserver/somewhere/rushscripts/submit-nuke.pl " +
                "-field Frames: %(sfrm)s-%(efrm)s " +
                "-field NukeScript: \"%(nukescript)s\" 2>&1 " ) % locals()
    if ( os.path.isdir("/var/tmp") ): cmd += "&"
    os.system(cmd)

nukebar = nuke.menu("Nuke")
item    = nukebar.addMenu("Rush", "icon.png")
item.addCommand('Submit', 'RushSubmit()')
---- snip

	When you click the item, the rush submit form should pop up
	with the Frames: and Nuke Script: fields filled out for you
	with the currently loaded nuke file.

	Feel free to add more logic, eg. to warn the user if no nuke
	file is loaded, or the current nuke script has not been saved
	before submitting. I kept the above example simple so you can
	see clearly what's going on.

	You can paste the above into the nuke script editor to test it
	(see "TUTORIAL" instructions in my last posting for how to do that),
	and when you have it all working, you can add it to nuke's menu.py file.

	In the above, you MUST change "//yourserver/somewhere/rushscripts/submit-nuke.pl"
	to be the path where your submit-nuke script lives.

	Note this example assumes you're using a semi-recent submit-nuke.pl
	that allows the -field command line options.

	Regarding the 'menu.py' file, if you add it to the one in the Nuke
	directory, it will appear for all users. eg:

		Linux: /usr/local/Nuke6.1v1-32/plugins/menu.py
		Windows: c:/program files/nuke6.1v1/plugins/menu.py

	Or, if you add it to your home directory ~/.nuke/menu.py,
	then it will just work for you. (a good way to test, if you
	don't have root/administration perms)

	Let me know if you have any questions.

[EDITED FOR CLARITY - erco 11/10/10]

-- 
Greg Ercolano, erco@(email surpressed)
Seriss Corporation
Rush Render Queue, http://seriss.com/rush/
Tel: (Tel# suppressed)ext.23
Fax: (Tel# suppressed)
Cel: (Tel# suppressed)

   From: Craig Allison <craig@(email surpressed)>
Subject: Re: Nuke Submit...
   Date: Fri, 12 Nov 2010 05:59:41 -0500
Msg# 1974
View Complete Thread (7 articles) | All Threads
Last Next
That's a great help, I'd already added the submit to the central menu.py =
but it wasn't pulling through those values, this will make it much nicer =
for the guys.

Only thing I had to add to the centralised script was the declaration:

"import nuke, os"

before

> nukescript = nuke.Root().name()



Awesome as ever Greg, thank you!

Craig


Craig Allison
Digital Systems & Data Manager
The Senate Visual Effects


On 11 Nov 2010, at 01:13, Greg Ercolano wrote:

> [posted to rush.general]
> 
>> Craig Allison wrote:
>>> Has anyone done a Nuke submit script that auto pulls in all the basic
>>> requirements for rendering from the current open script (i.e. Script
>>> path, frames etc.)?
>>> 
>>> Looking to get our current submit a little more elegant so any tips
>>> gratefully received!
> 
> 	Here's something simple that adds a Rush/Submit item
> 	to the nuke menu bar:
> 
> ---- snip
> def RushSubmit():
>    nukescript = nuke.Root().name()
>    sfrm = nuke.Root().firstFrame()
>    efrm = nuke.Root().lastFrame()
>    cmd = ( "perl //yourserver/somewhere/rushscripts/submit-nuke.pl " +
>                "-field Frames: %(sfrm)s-%(efrm)s " +
>                "-field NukeScript: \"%(nukescript)s\" 2>&1 " ) % locals()
>    if ( os.path.isdir("/var/tmp") ): cmd += "&"
>    os.system(cmd)
> 
> nukebar = nuke.menu("Nuke")
> item    = nukebar.addMenu("Rush", "icon.png")
> item.addCommand('Submit', 'RushSubmit()')
> ---- snip
> 
> 	When you click the item, the rush submit form should pop up
> 	with the Frames: and Nuke Script: fields filled out for you
> 	with the currently loaded nuke file.
> 
> 	Feel free to add more logic, eg. to warn the user if no nuke
> 	file is loaded, or the current nuke script has not been saved
> 	before submitting. I kept the above example simple so you can
> 	see clearly what's going on.
> 
> 	You can paste the above into the nuke script editor to test it
> 	(see "TUTORIAL" instructions in my last posting for how to do that),
> 	and when you have it all working, you can add it to nuke's menu.py file.
> 
> 	Just be sure to at least change "//yourserver/somewhere/rushscripts/submit-nuke.pl"
> 	to where you have your submit-nuke script.
> 
> 	Note this assumes you're using a semi-recent submit-nuke.pl script
> 	that allows the -field command line options.
> 
> 	Regarding the 'menu.py' file, if you add it to the one in the
> 	Nuke directory, it will appear for all users. eg:
> 
> 		Linux: /usr/local/Nuke6.1v1-32/plugins/menu.py
> 		Windows: c:/program files/nuke6.1v1/plugins/menu.py
> 
> 	Or, if you add it to your home directory ~/.nuke/menu.py,
> 	then it will just work for you. (a good way to test, if you
> 	don't have root/administration perms)
> 
> 	Let me know if you have any questions.
> 

   From: Urs Franzen <u.franzen@(email surpressed)>
Subject: Re: Nuke Submit...
   Date: Tue, 18 Jan 2011 10:14:52 -0800
Msg# 1991
View Complete Thread (7 articles) | All Threads
Last Next
I had a similar problem, I first went a different way to send to rush,
which ended in a mess with no BatchClip, lots of retries, unrendered frames
(cant rename temp to final....)
this works great, but is there an option to hide the interface? so I don't
have to press submit?
or will this bust everything?

what I did before switching to gregs solution was this:

def ufrSendToRush():
    nuke.scriptSave()
    n=nuke.thisNode()
    vshot =
n.knob('seq').value()+'_'+n.knob('subseq').value()+'_'+n.knob('numb').value()
    vartist=n.knob('artist').value()
    vversion='v'+n.knob('version').value().zfill(3)
    title=vshot+'_'+vartist+'_'+vversion
   
frames=str(nuke.toNode('Read1').knob('first').value())+'-'+str(nuke.toNode('Read1').knob('last').value())
    logdir=('/Boutique/Jobs/.rushlogs')
    command='perl /Boutique/common/rushscripts/submit-nuke.pl -render  ' +
nuke.root().knob('name').value() + ' 5 0 3 Fail Licpause+Retry 0 off -V'
    cpus='+farm=12'
    # COMBINE VARIABLES
    render='title '+title+'\n'+'frames '+frames+'\n'+'logdir
'+logdir+'\n'+'command '+command+'\n'+'cpus '+cpus+'\n'
    # SUBMIT THE JOB
    submit = os.popen("rush -submit", 'w')
    submit.write(render)
    err = submit.close()
    if err:
	nuke.message('submit failed, error code: '+str(err))
    else:
        nuke.message('sent to farm, be happy!')

what was my mistake?

cheers, urs


Craig Allison <craig@(email surpressed)> wrote:
> That's a great help, I'd already added the submit to the central menu.py =
> but it wasn't pulling through those values, this will make it much nicer =
> for the guys.
> 
> Only thing I had to add to the centralised script was the declaration:
> 
> "import nuke, os"
> 
> before
> 
>> nukescript = nuke.Root().name()
> 
> 
> 
> Awesome as ever Greg, thank you!
> 
> Craig
> 
> 
> Craig Allison
> Digital Systems & Data Manager
> The Senate Visual Effects
> 
> 
> On 11 Nov 2010, at 01:13, Greg Ercolano wrote:
> 
>> [posted to rush.general]
>> 
>>> Craig Allison wrote:
>>>> Has anyone done a Nuke submit script that auto pulls in all the basic
>>>> requirements for rendering from the current open script (i.e. Script
>>>> path, frames etc.)?
>>>> 
>>>> Looking to get our current submit a little more elegant so any tips
>>>> gratefully received!
>> 
>> 	Here's something simple that adds a Rush/Submit item
>> 	to the nuke menu bar:
>> 
>> ---- snip
>> def RushSubmit():
>>    nukescript = nuke.Root().name()
>>    sfrm = nuke.Root().firstFrame()
>>    efrm = nuke.Root().lastFrame()
>>    cmd = ( "perl //yourserver/somewhere/rushscripts/submit-nuke.pl " +
>>                "-field Frames: %(sfrm)s-%(efrm)s " +
>>                "-field NukeScript: \"%(nukescript)s\" 2>&1 " ) % locals()
>>    if ( os.path.isdir("/var/tmp") ): cmd += "&"
>>    os.system(cmd)
>> 
>> nukebar = nuke.menu("Nuke")
>> item    = nukebar.addMenu("Rush", "icon.png")
>> item.addCommand('Submit', 'RushSubmit()')
>> ---- snip
>> 
>> 	When you click the item, the rush submit form should pop up
>> 	with the Frames: and Nuke Script: fields filled out for you
>> 	with the currently loaded nuke file.
>> 
>> 	Feel free to add more logic, eg. to warn the user if no nuke
>> 	file is loaded, or the current nuke script has not been saved
>> 	before submitting. I kept the above example simple so you can
>> 	see clearly what's going on.
>> 
>> 	You can paste the above into the nuke script editor to test it
>> 	(see "TUTORIAL" instructions in my last posting for how to do that),
>> 	and when you have it all working, you can add it to nuke's menu.py file.
>> 
>> 	Just be sure to at least change "//yourserver/somewhere/rushscripts/submit-nuke.pl"
>> 	to where you have your submit-nuke script.
>> 
>> 	Note this assumes you're using a semi-recent submit-nuke.pl script
>> 	that allows the -field command line options.
>> 
>> 	Regarding the 'menu.py' file, if you add it to the one in the
>> 	Nuke directory, it will appear for all users. eg:
>> 
>> 		Linux: /usr/local/Nuke6.1v1-32/plugins/menu.py
>> 		Windows: c:/program files/nuke6.1v1/plugins/menu.py
>> 
>> 	Or, if you add it to your home directory ~/.nuke/menu.py,
>> 	then it will just work for you. (a good way to test, if you
>> 	don't have root/administration perms)
>> 
>> 	Let me know if you have any questions.
>>

   From: Greg Ercolano <erco@(email surpressed)>
Subject: Re: Nuke Submit...
   Date: Tue, 18 Jan 2011 14:34:31 -0500
Msg# 1992
View Complete Thread (7 articles) | All Threads
Last Next
Urs Franzen wrote:
> this works great, but is there an option to hide the interface? so I don't
> have to press submit? or will this bust everything?

	The technique shown brings up the interface to allow the
	user to make changes to the form before submitting,
	as there are often Nuke command line flags or options
	for memory or threads the user might want to change.

	If you don't want to bring up the interface, then you'd
	invoke the submit script this way instead:

		/path/to/submit-xxx.pl -submit <filename.txt>

	..where <filename.txt> is a simple file containing "Key: value"
	pairs that have all the settings from the interface.

	Every time you submit a job, one of these files is created in:

		Unix:  ~/.rush/.submit-nuke-last
		Windows: c:\tmp\.rush-<USERNAME>\.submit-nuke-last

	..so you can use that for reference when crafting a script
	to make your own.

-- 
Greg Ercolano, erco@(email surpressed)
Seriss Corporation
Rush Render Queue, http://seriss.com/rush/
Tel: (Tel# suppressed)ext.23
Fax: (Tel# suppressed)
Cel: (Tel# suppressed)

   From: Greg Ercolano <erco@(email surpressed)>
Subject: Re: Nuke Submit...
   Date: Tue, 18 Jan 2011 11:50:03 -0800
Msg# 1993
View Complete Thread (7 articles) | All Threads
Last Next
Oh, and regarding this:

Urs Franzen wrote:
> def ufrSendToRush():
>     nuke.scriptSave()
>     n=nuke.thisNode()
>     vshot = n.knob('seq').value()+'_'+n.knob('subseq').value()+ \
>                                   '_'+n.knob('numb').value()
>     vartist=n.knob('artist').value()
>     vversion='v'+n.knob('version').value().zfill(3)
>     title=vshot+'_'+vartist+'_'+vversion
>    
>     frames=str(nuke.toNode('Read1').knob('first').value())+'-'+\
>            str(nuke.toNode('Read1').knob('last').value())
>     logdir=('/Boutique/Jobs/.rushlogs')
>     command='perl /Boutique/common/rushscripts/submit-nuke.pl -render  ' + \
>              nuke.root().knob('name').value() + ' 5 0 3 Fail Licpause+Retry 0 off -V'
>     cpus='+farm=12'
>     # COMBINE VARIABLES
>     render='title '+title+'\n'+\
>            'frames '+frames+'\n'+\
>            'logdir '+logdir+'\n'+\
>            'command '+command+'\n'+\
>            'cpus '+cpus+'\n'
>     # SUBMIT THE JOB
>     submit = os.popen("rush -submit", 'w')
>     submit.write(render)
>     err = submit.close()
>     if err:
> 	nuke.message('submit failed, error code: '+str(err))
>     else:
>         nuke.message('sent to farm, be happy!')
> 
> what was my mistake?

	Hmm, in this type of usage, you're firing up 'rush -submit'
	directly, and hoping you get the command line arguments in
	the right order.

	I'm guessing if you had any trouble with this technique, I'd
	look to that 'command=' line to make sure everything after -render
	is really the flags that your submit-nuke.pl script expects, eg:
	/Boutique/common/rushscripts/submit-nuke.pl

	You can determine these values empirically by just submitting
	the job normally through the submit interface, then using
	'Job Edit' to inspect the command.

	Or, you can look at the submit-nuke.pl script to see what arguments
	it expects when the -render flag is passed in.

	Based on the above, it appears to be passing the script:

nuke.root().knob('name').value() + ' 5 0 3 Fail Licpause+Retry 0 off -V'
|_________________________________|  | | | |      |            | |    |
      Nuke Script                    | | | |      |            | |    Nuke Flags
                                     | | | |      |            | Print Environment
                                     | | | |      |            Max Log Size
                                     | | | |      License Behavior
                                     | | | Retry behavior
                                     | | Retries
                                     | Batch end (depends on your frame range!)
                                     Batch Frames

	(The above 'ascii art' assumes you're reading this in a fixed width font!)

	Most of that looks OK, though I don't think Batch End should be zero.
	If your frame range is 1-112 and batching is set to 5, the Batch End should be 112,
	the last frame in the frame range.

	Also, make sure 'Nuke Script' is an /absolute pathname/ to the
	Nuke script, and not just the filename without the leading path.

	If you still want to use this technique and are having trouble
	even with the above advice, email me directly: a) your submit-nuke.pl
	script, b) the complete frame log from the failed render, and I can
	probably tell you what's wrong.