Custom MAXScript Submission - PostLoadScript

I’ve followed the Custom MAXScript Submission Tutorial from the online documentation, but ran into one problem I can’t find an answer for.

I’m using SMTDSettings.PostLoadScriptFile to call an external ms file but it’s trying to find it in “\renderbox\c$\Users\render\AppData\Local\Thinkbox\Deadline\slave\renderbox\jobsData” instead of the unc path I provided. What’s missing here? Code is below.

EDIT: I found this section in SubmitMaxToDeadline_Functions.ms. It appears to be stripping the filename from the path, but this is already past my point of understanding. I just need a way to copy the PostLoadScript to the local render temp dir.

if SMTDSettings.RunPostLoadScript do format "PostLoadScript=%\n" (FileNameFromPath SMTDSettings.PostLoadScriptFile) to:JobInfoFile

[code](
global SMTDSettings
global SMTDFunctions

local theNetworkRoot = @"\3d\deadrepo5"
local remoteScript = theNetworkRoot + @"\submission\3dsmax\SubmitMaxToDeadline_Functions.ms"
fileIn remoteScript

SMTDFunctions.loadSettings()
SMTDSettings.JobName = maxFileName + " - [MXS]"
SMTDSettings.ChunkSize = 1
SMTDSettings.group = “sim”
SMTDSettings.ShowFrameBuffer = true
SMTDSettings.SequentialJob = true
SMTDSettings.RunPostLoadScript = true
SMTDSettings.PostLoadScriptFile = @"\3d\3ddata\resources\Max\simOnDeadline_default.ms"

local maxFileToSubmit = SMTDPaths.tempdir + maxFileName
SMTDFunctions.SaveMaxFileCopy maxFileToSubmit

local SubmitInfoFile = SMTDPaths.tempdir + “\max_submit_info.job”
local JobInfoFile = SMTDPaths.tempdir + “\max_job_info.job”

SMTDFunctions.CreateSubmitInfoFile SubmitInfoFile
SMTDFunctions.CreateJobInfoFile JobInfoFile

local initialArgs="""+SubmitInfoFile+"" “”+JobInfoFile+"" “”+maxFileToSubmit+"" "
SMTDFunctions.waitForCommandToComplete initialArgs SMTDSettings.TimeoutSubmission
)–end script[/code]

It is actually simpler than it seems.
The Script files are all sent with the job as auxiliary files. This ensures that if you modify the script at its original location while the job is running, the job will not be affected. In other words, we SNAPSHOT a copy of the script and pass it to the submitter arguments line right after the .JOB and .MAX files. This is why the internal JOB file property has the path stripped from the file name - the script is expected to be in the job’s folder next to the MAX file! All you have to do is grab the original file path from the script property and pass it to the submitter as part of the command line arguments, like this:

local initialArgs="\""+SubmitInfoFile+"\" \""+JobInfoFile+"\" \""+maxFileToSubmit+"\" \""+SMTDSettings.PostLoadScriptFile+"\"" SMTDFunctions.waitForCommandToComplete initialArgs SMTDSettings.TimeoutSubmission

Any files passed to the command line will be automatically copied to the job folder by the submitter.
Then, when a slave picks up the job, the auxiliary files will also be copied to its local temp. folder and the Slave will execute the script from there.

NOTE that you can still go to the Job folder (Ctrl+D in Monitor) and modify the script copy in place after the submission, but you must check the option to sync. all auxiliary files under the Advanced tab of the Job Properties for the modified copy to be updated on all slaves!

Also don’t forget to returns TRUE at the end of the post load script (or FALSE if you want to to fail the task). A lot of people forget that part…

Thank you, that worked. I wasn’t aware I could call SMTDSettings like that.

I’m not sure what you mean by returning TRUE at the end of the script. What does it accomplish? Does it pass a result code back to deadline?