Houdini internally has a “global current node”, similar to a current directory in a file system.
When submitting a deadline job, that current node is the deadline ROP and not the redshift ROP.
I can get this node by printing hou.pwd() in hrender_dl.py
In OP’s case, this would print “SUBMIT”.
This global current node is the node that houdini uses when expanding strings with hou.text.expandString()
that contain the $OS token.
Therefore, if the output path contains $OS, houdini will expand it to “SUBMIT” (or whatever name the deadline rop has) and deadline will create a folder with that name, regardless of the redshift ROPs name.
To fix this, we can manually set the global current node to the actual render rop using hou.cd() before expanding the output path.
Here’s the code before changes:
# create the output directory
output_folder_unexpanded = os.path.dirname(output)
output_folder = hou.expandString(output_folder_unexpanded)
if not os.path.isdir(output_folder):
try:
print( 'Creating the output directory "%s"' % output_folder )
os.makedirs(output_folder)
except:
print( 'Failed to create output directory "%s". The path may be invalid or permissions may not be sufficient.' % output_folder )
raise
Here’s the code after changes:
# create the output directory
houdini_pwd = hou.pwd()
hou.cd(driver)
output_expanded = hou.text.expandString(output)
output_folder = os.path.dirname(output_expanded)
hou.setPwd(houdini_pwd)
if not os.path.isdir(output_folder):
try:
print( 'Creating the output directory "%s"' % output_folder )
os.makedirs(output_folder)
except:
print( 'Failed to create output directory "%s". The path may be invalid or permissions may not be sufficient.' % output_folder )
raise
I set the global current node to the “driver”, which is a variable set by deadline at the beginning of the script and is the actual redshift ROP, and in the end set the current node back to what it was before, just so that we don’t break anything further down the line.
Please note that I also reversed the order of the two lines “dirname” and “expandString”.
If the output path contains an expression like chs("../null/outpath")
, then the path needs to be expanded BEFORE getting the dirname. Otherwise dirname will split the string in the middle of an expression, which makes no sense.