Executing the CurveTool

We ran into an issue one day of trying to run a group on the farm.  One of the nodes within the group was a CurveTool with "Curve Type" ("operation" knob) set to "Max Luma Pixel".

CurveTool

We had to get the CurveTool to run for the WHOLE frame range BEFORE the script could render because there were some expressions that were dependent upon the max and min data for the whole range.  So there were 2 solutions we thought of:

  1. Run the CurveTool before you send to the farm.
  2. Send to the farm and run the curve tool before the render.

The second solution was ideal because the techs didn't want to wait for the CurveTool to finish before they could work on the next script.  Send it to the farm and let the farm worry about it.  But how do you do that?

nuke_execute

According to the API, nuke.execute() can take a node and "execute" it if it has specific code to do so.  For instance, the Write node has a "Render" button that's executed.  So in this case, we use nuke.execute() to run the Curve tool for the frame range we need.  For our purposes we passed in the name of the node and the first and last frame and put in the "beforeRender" knob in the write node that would be used to render.

write_node

This worked... but it was inefficient.  The farm split the render script across a bunch of machines (which is the point of the farm).  On each machine, it was executing the curve tool for the whole frame range before the write node rendered its little section of the render.  Each script was executing the whole range in the curve tool just to render a few frames.

So we thought of a 3 option:

  • Create a job that executes the whole range in the curve tool, save the script, and create a render job using the same script.

So we did just that.  In the CurveTool's Python tab, we put the following code in the "afterFrameRender" knob: 

We ran into some issues with just calling nuke.scriptSave(); using nuke.scriptSaveAs was good because it has an 'overwrite' argument.

But then we ran into another problem: how do we get it to execute on the farm?

Well when we send things to the farm, we're actually sending a command line to execute.  When accessing the command-line help for Nuke, there is an option for supplying the names of the nodes to render:

It says "execute" instead of "render", so that gave us hope.  So we created a job that passed the name of the CurveTool, which is "GroupName.CurveToolName" when it's inside a group.  Once executed on the farm, the script had all it needed to render on multiple machines.

So in the end, I didn't actually use nuke.execute(), but it sent me down the collaborative rabbit hole that led to the solution.  I'm looking into taking this to the next logical step, which is to get the keyframes from the CurveTool written out to separate files or to database entries so the script can be run on several machines at once.  They'll then be collected and will populate the CurveTool before the render happens on multiple machines.  I'm sure we'll find the best way to do it eventually.  Just like with the original CurveTool problem, I know it can be done.  We'll just have to fall down that rabbit hole when we get to it.