Why doesn't my PreLoad Script get sent with the job?

So I have a custom deadline submitter in one of my tools…

I’ve specified a post load script…

thefile = “Y:\TEMP\HydraGen\Tree.ms”
SMTDSettings.PostLoadScriptFile = thefile
SMTDSettings.RunPostLoadScript = true

…but the script file isn’t being copied to the repository, I’m assuming my simplified submitter is missing the code to collect the needed script file.

D

[code]–struct nodeDeadline(tilesrendering,XTiles,YTiles,restartrenderer,priority,group,machinelimit,ignoredlls,regionrendering,croptilesrendering,regiontop,regionleft,regionbottom,regionright,singletilejob,submitdependent,cleanuptiles,usenodesettings)
(
rendSaveFile = true
global SMTDSettings --this is the global variable that will contain the submission settings of SMTD
global SMTDFunctions --this is the global variable that will contain the submission functions of SMTD

			   local theNetworkRoot = "" --this variable will hold the network root path - the path to the Repository
			   local theHomeRoot = "" --this variable will hold the local home folder of Deadline


			   --------------------------------------
			   --MAIN SUBMISSION CODE
			   --------------------------------------
				 
				  theNetworkRoot = "\\\\bluearc.taylorjames.com\\DeadlineRepository" --repository location
				  format "Network Root is '%'\n" theNetworkRoot
						   
				  --First, we load the script file with the function definitions
				  local remoteScript = theNetworkRoot + "\\submission\\3dsmax\\SubmitMaxToDeadline_Functions.ms"  --this is the file name on the Repository
				  local localScript = getDir #userscripts + "\\SubmitMaxToDeadline_Functions.ms" --to speed things up, we will copy it locally first, then we will load it
				  if doesFileExist remoteScript then --if the remote file exists,
				  (
					deleteFile localScript --we delete the local file in case it exists already
					copyFile remoteScript localScript --then we copy the remote file over
					fileIn localScript quiet:true --and execute it (equivalent to Main Menu > MAXScript > Run Script...)
					 
					--At this point, SMTDFunctions should have been initialized to the latest version found on the Repository.
					--Now we have to make sure all defaults (both global and local) are loaded, otherwise the SMTDSettings struct would contain factory defaults
					SMTDFunctions.loadSettings()
												   
					local TempMaxFile = maxfilepath + maxfilename
					f = maxfilepath + maxfilename
					  
					SMTDSettings.JobName = getFileNameFile TempMaxFile + " [HydraGen Submission]" --we could for example set the job name to the name of the max file and any custom text we want
					SMTDSettings.Comment = "Submitted from HydraGen" --we could set the comment field
					SMTDSettings.Priority = n.priority --we can override the priority, for example we could increment the priority based on the order of the files or something else
					SMTDSettings.Group = n.group
					SMTDSettings.ChunkSize = 1
					SMTDSettings.restartrenderer = n.restartrenderer
					SMTDSettings.ignoreMissingDLLs = n.ignoredlls
					SMTDSettings.machinelimit = n.machinelimit
					SMTDSettings.SubmitSceneMode = #reposave --changed to +Mode in Deadline 5.1
					  
					SMTDSettings.PostLoadScriptFile = thefile
					SMTDSettings.RunPostLoadScript = true
					
					--##todo 
					--n.usenodesettings
					SMTDSettings.regionrendering = n.regionrendering
					SMTDSettings.regiontop = n.regiontop
					SMTDSettings.regionleft = n.regionleft
					SMTDSettings.regionbottom = n.regionbottom
					SMTDSettings.regionright = n.regionright
					
					
					--If it's a tile render.....
					if n.tilesrendering == true then
					(
						SMTDSettings.TilesRendering = n.tilesrendering --we don't really have to enable this, because the call to spawnTileJobs() will set it to true anyway
						SMTDSettings.TilesInX = n.xTiles --we define the horizontal tiles count
						SMTDSettings.TilesInY = n.yTiles --and the vertical tiles count
						SMTDSettings.SingleTileJob = n.singletilejob --we will submit a single frame as one job where each task will represent a tile
						SMTDSettings.SingleTileJobDependent = n.submitdependent --we will submit a dependent job to combine the tiles
						SMTDSettings.SingleTileJobCleanup = n.cleanuptiles --and we will clean up after us, leaving the assembled image but deleting the tiles files. Set to false if you want to rerender later.
						retCode = SMTDFunctions.spawnTileJobs forceMaxFile:TempMaxFile  --this is the function that does all the useful work spawning the tile render
						
						--Once the command returns, we can try to get the message from the message file. Even if it failed, the file could contain userul error info...
						local renderMsg = SMTDFunctions.getRenderMessage()
						SMTDFunctions.getJobIDFromMessage renderMsg --we can also extract the job ID from the render message - it will be stored in SMTDSettings.DeadlineSubmissionLastJobID
						
							
						if retCode == true then --retCode returns true from SMTDFunctions.spawnTileJobs() if sucessful.
						(
							format "File % submitted successfully as Job %.\n\n%\n\n" (filenameFromPath TempMaxFile) SMTDSettings.DeadlineSubmissionLastJobID renderMsg
							SMTDFunctions.CopyExternalFilesToRepository() --copy files to main job
						)   
						else --if the code was anything else, we print the message as error message
							format "Job Submission FAILED.\n\n%" renderMsg
					)
					else
					(
						--Note that the simple act of loading SMTDFunctions has also initialized a SMTDPaths struct with default paths - type 'show SMTDPaths' to see what paths are available
						local SubmitInfoFilename = SMTDPaths.tempdir + "\\max_submit_info.job"  --we define the submit info file name which will contain info about the submission settings
						local JobInfoFilename = SMTDPaths.tempdir  + "\\max_job_info.job" --and the job info file which will contain info about the job's settings (most of them can be changed in the job's Properties dialog of the Monitor
			
						SMTDFunctions.CreateSubmitInfoFile SubmitInfoFilename --we then call the function to create a submit info file based on the current SMTDSettings values
						
						--We also call the function to create a job info file. It will contain all info about the current scene like renderer settings, list of cameras etc.
						--This function accepts optional overrides for the render output filename, the tiles to render and the camera to render. 
						--We can specify these if we know them: renderOutputOverride:"" tileString:"" forceCamera:"" 
						SMTDFunctions.CreateJobInfoFile JobInfoFilename  --renderOutputOverride: could be set to a string that points at the network location to write the images from the scene being submitted instead of using the renderer's output settings!
							
						--Now that we have all the files we need for a submission (the scene file, the submit info and the job info file), we can call the submitter!
						--To do this, we will have to create an argument list to pass to DeadlineCommandBG
						local initialArgs = "\"" + SubmitInfoFilename + "\" \"" + JobInfoFilename  + "\" \"" + f + "\" " 
						
						--We call the DeadlineCommandBG with our arguments and the timeout (which you can customize)
						local retcode = SMTDFunctions.waitForCommandToComplete initialArgs SMTDSettings.TimeoutSubmission
						
						--Once the command returns, we can try to get the message from the message file. Even if it failed, the file could contain userul error info...
						local renderMsg = SMTDFunctions.getRenderMessage() 
						SMTDFunctions.getJobIDFromMessage renderMsg --we can also extract the job ID from the render message - it will be stored in SMTDSettings.DeadlineSubmissionLastJobID
						
						if retCode == #success then --if the return code from the call was #success, we show a positive message
						(
							format "File % submitted successfully as Job %.\n\n%\n\n" (filenameFromPath f) SMTDSettings.DeadlineSubmissionLastJobID renderMsg
							SMTDFunctions.CopyExternalFilesToRepository() --copy files to main job
						)	
						else --if the code was anything else, we print the message as error message
							format "Remaining Frames Job Submission FAILED.\n\n%" renderMsg 
					)			
					
					 
			   )--end if root resolved
			)--end script[/code]

You’ll need to specify it in the arguments being passed to deadline command. For example:

 local initialArgs = "\"" + SubmitInfoFilename + "\" \"" + JobInfoFilename  + "\" \"" + f + "\" \"" + postLoadScript + "\"" 

Where postLoadScript contains the full path to the script file.

Hope that helps!

  • Ryan

Cheers Russell, that works! Just need to solve all my other bugs now :slight_smile: