AWS Thinkbox Discussion Forums

Can auxiliary files be added for anything? Not able to get it working with Maya startup script

I’m attempting to get the submitter I’ve coded work so that people can submit Python scripts to run before a render starts. I found the “StartupScript” option is only available on MEL files (at least in Deadline 9), so I had the idea of intercepting Python files and instead writing and sending a MEL file to call them.

I’m not really sure how auxiliary files work so this may have been for nothing, but I assumed a name without a path would look in that folder, but it doesn’t seem to be the case.

So this is what I’m doing if the input is “X:/folder/someMayaScript.py”:

  1. Generate mel filename (someMayaScript.mel)
  2. Save mel to temp directory containing the text python(“execfile(‘X:/folder/someMayaScript.py’)”);
  3. Add mel file as auxiliary file, so it doesn’t matter if it’s on a network drive or not
  4. Set “StartupScript” value to “someMayaScript.mel

Although the mel file is successfully submitted with the job, it’s not able to run. Putting a direct path to the file works correctly though, but that would require needlessly saving all the temp files on the network.

Is there a way I could keep this clean and only store the mel file on the local machine?

DeadlineCommand needs full paths to any file. I believe to load libraries correctly we always set the working directory to Deadline’s “bin” folder, but I’m not 100% sure that’s right.

Aux files are going to be copied to the Repo and then downloaded to the render nodes when the job starts. You won’t be able to bake the script path into your Mel because the temporary folder that it’ll be copied to should be unique on each run. You’ll have to use job.JobAuxiliarySubmissionFileNames to get where the Slave has copied them to. There are quite a few examples, so feel free to dig around in “[repo]/plugins/” for examples.

Thanks for the reply, I guess that’s useful to know for where the actual executables are.
For the record the path to the python script is permanently accessible to anything on the network, I was just trying to have it use the mel file from its own temp directory. I’ve set it up to copy to a temporary network location now anyway so it’s not a huge issue, it just made me realise I still have a lot to learn haha.

It works correctly when submitting a Maya script job, or adding one of the pre/post scripts, but I don’t think the StartupScript option has been given much love, especially since it doesn’t support Python :slight_smile:

It’s supposed to support Python:

image

I’m just going by the UI here and I haven’t tested it myself. Did throwing a .py in there fail?

As far as the learning, that’s what we’re here for. Feel free to throw any and all questions our way. I’m sure it’ll help future generations. :smiley:

Oh yeah the Script Job Python works fine haha. I haven’t done a huge amount of testing but it works well with aux files from what I’ve seen. It’s the part just above that option.
The Command Line Args and Startup Script fields are enabled depending if the MayaBatch plugin is loaded or not, and it’s the Startup Script option I was having the issues with.

I’ve just noticed it does actually seem to support Python (the default is mel), but for whatever reason it doesn’t appear to be able to execute it. I’m getting a strange error saying “line 1.0: invalid directive”, where line 1 is a comment.

I’ve just sent off another job with the Python encoding comment thing at the top to see if that was the issue, probably won’t be finished by the time I leave though. (edit: it’s not fixed it haha, we’re on DL 9 though so maybe there’s been changes since)

Mmm. Not much changed with regard to script jobs since Deadline 7.2. Have you tried with just a script that prints some text or similar?

Bit late, but I’ve found the actual issue to that weird error, it’s actually evaluating all code as MEL, so even if a .py file is linked, it’ll fail as it’s not able to execute

Hmm. I did some quick digging and this is what should differentiate the two in MayaBatch.py:

# Execute either MEL or Python script based on file extension provided.
if os.path.splitext( self.ScriptFilename )[1].lower() == ".py":
    self.WriteStdinToMonitoredManagedProcess( self.ProcessName, 'eval( "python( \\"execfile( \\\\\\"' + self.ScriptFilename.replace( "\\", "/" ) + '\\\\\\" )\\" );" );' )
else:
    self.WriteStdinToMonitoredManagedProcess( self.ProcessName, 'eval( "source \\"' + self.ScriptFilename.replace( "\\", "/" ) + '\\";" )' )

Can you check and see what “ScriptFilename” is in the “Submission Params” of the job you tested with? It’ll be on the “Plugin Info” side.

Thanks for the digging haha, that code does appear but the permissions on the folder are locked down super tight by IT so I’m not really able to edit it currently.

I’m not 100% sure that code isn’t for other things though, for example it seems to be specifically for a script job (as in different to the startup script) in this code here, but in other places seems to contain generated MEL code from the “WriteBatchScriptFile” function:

        # This is script job, so we'll just execute the given script.
        self.ScriptFilename = self.GetPluginInfoEntry( "ScriptFilename" )
        if not Path.IsPathRooted( self.ScriptFilename ):
            self.ScriptFilename = Path.Combine( self.GetJobsDataDirectory(), self.ScriptFilename )

        if( not File.Exists( self.ScriptFilename ) ):
            self.FailRender( "MEL/Python Script File is missing: %s" % self.ScriptFilename )

A search for “startup” revealed this part, which if it happens to be the actual code, doesn’t have that .py check.

    # Need to execute the startup script now, after the scene has been loaded.
    if self.StartupScriptPath != "":
        scriptBuilder.AppendLine( 'if (!$loadFailed) {' )
        scriptBuilder.AppendLine( 'string $startupScriptName = "' + self.StartupScriptPath.replace( "\\", "/" ) + '";' )
        scriptBuilder.AppendLine( 'print ("Executing startup script: " + $startupScriptName + "\\n");' )
        scriptBuilder.AppendLine( 'eval( "source \\"" + $startupScriptName + "\\";" );' )
        scriptBuilder.AppendLine( '}' )

Good point! Okay, I’ll circle back around in there and take a closer look.

There are quite a few places we’re writing Melscript for things then executing it, and I saw similar areas and had to trace back where the variables like “StartupScriptPath” are coming from. If they’re set as random file names then it’s usually not user-provided scripts as we’d execute them wherever they’re found.

At least, I don’t think we perform path mapping on the scripts folks feed into it.

Privacy | Site terms | Cookie preferences