Custom Sanity check py file to create directories before rendering on nuke

Hi,

I’d like to write a little script that creates a directory when a render is submitted from Nuke’s Deadline Submitter. Could I use CustomSanityChecks.py for that? For now I tried setting up the script like this without success;

def RunSanityCheck():
for node in nuke.selectedNodes():
if node.Class() == ‘WriteTank’:
sequence = os.path.join(
node.knobs()[‘path_context’].value(),
node.knobs()[‘path_local’].value(),
node.knobs()[‘path_filename’].value()
)
folder = os.path.dirname(sequence)
if os.path.exists(folder) == True:
None
else:
os.makedirs(folder)

Nuke write node common callbacks to create directories does not seem to be working when I submit the render through deadline instead of rendering in the nuke GUI. Has anyone had a similar issue and fixed it through sanitycheck.py file?
Any help will be appreciatted.
Many thanks,

Joan

Hey Joan,

I can’t offer any assistance on the sanity check script (I’ve only used it for setting submitter defaults). BUT, I might suggest taking a look at creating a JobPreLoad.py script for Nuke to handle this. You could loop through the JobOutputDirectories property to check and create the output directories if they don’t exist.

Here’s an example of the script.

# Nuke JobPreLoad.py example
from System import *
from System.IO import *
from Deadline.Scripting import *
import os

def __main__(deadlinePlugin):

    job = deadlinePlugin.GetJob()
    
    for i in range(0, len(job.JobOutputDirectories)):
        
        path = str(job.JobOutputDirectories[i]).replace("\\", "/")
        
        if not os.path.exists(path):
            ClientUtils.LogText("created output dir: {}".format(path))
            os.makedirs(path)

Hope this helps!

Best,
-Alex

1 Like

Ooo! We might need to change the title for folks to find if Joan doesn’t mind. I think this would be nice for folks to use (or for us to bundle into Deadline’s Nuke plugin).

1 Like

Hi Chitty,

Many thanks indeed for your help and suggestions.
I’ll give it a try right now!