Setting dependencies via Maxscript

Discussion and Support of Deadline, the Render Management System
jordiCanela
Posts: 2
Joined: Fri May 12, 2017 8:24 am

Setting dependencies via Maxscript

Postby jordiCanela » Fri May 12, 2017 5:07 pm

Hi,

I am implementing Deadline submission for a script that sends batch renders of animated cameras. The script sends first all the GI prepasses for each camera in the scene and then all the main passes.

I know the suggested method by Bobo is to send pairs of prepass & main pass creating for the main pass a dependency on the last submitted job like this:

Code: Select all

SMTDSettings.DependOnPreviousJobMode = #last
SMTDSettings.DependencyJobItems = #{1}


I can not use this method as I still want to send first all the GI prepasses and then the Main passes.

Instead, I can write a submission function that sets a dependency to a specific job sent in the current session by passing the job ID of the prepass. Here is the pertinent fragment of code:

Code: Select all


--Note: svars is an instance of a struct containing submission variables.

if svars.isPrepass then
(
   lastJob = #(jobName, SMTDSettings.DeadlineSubmissionLastJobID, "", "", "", "", "", "")
   append SMTDSettings.PreviousJobsArray lastJob
)

if svars.isDependentJob then
(      
   SMTDSettings.SubmitAsDependent = true
   
   dependsOnJob = 0
   dependsOnJobID = undefined
   
   for previousJobIndex = 1 to SMTDSettings.PreviousJobsArray.count do
   (      
      --The variable cam contains a camera.
      --The name of the camera is also used to create the name of the GI prepases,
      --so I will look for that string in the SMTDSettings.PreviousJobsArray,
      if (findstring (SMTDSettings.PreviousJobsArray [previousJobIndex] [1]) svars.cam.name) != undefined do

      (
         dependsOnJob = previousJobIndex
         dependsOnJobID = SMTDSettings.PreviousJobsArray [previousJobIndex] [2]
      )
   )
   
   SMTDSettings.DependOnPreviousJob = True
   SMTDSettings.DependOnPreviousJobID = dependsOnJobID
)

else
(
   SMTDSettings.SubmitAsDependent = false
)




For some reason this doesn't work. The jobs are all submitted correctly, but dependencies are not set. All the prepass jobs are correctly stored inside the SMTDSettings.PreviousJobsArray and their ID's are correct.

What am I missing here?

Thanks,
Jordi

User avatar
Bobo
Posts: 5865
Joined: Tue Nov 15, 2005 10:26 am
Location: Vancouver, Canada
Contact:

Re: Setting dependencies via Maxscript

Postby Bobo » Fri May 12, 2017 6:43 pm

The properties

Code: Select all

   SMTDSettings.DependOnPreviousJob = True
   SMTDSettings.DependOnPreviousJobID = dependsOnJobID

are not used anymore - I checked the code, and they were left for safety to avoid crashes if some script still tries to access them, but they have not been in use for a veeeery looong time.

You still need to use the approach you mentioned in the beginning. You can populate the list of previous jobs with as many jobs as you want. Then you just set the mode to #previous, perform the search for the ones you want as you did in your code snippet, and set the SMTDSettings.DependencyJobItems bitarray to the indices of the jobs you want to depend on. The rest is magic.

Something like this:

Code: Select all

  SMTDSettings.DependencyJobItems = #{} --reset all bits to false
  for i= 1 to SMTDSettings.PreviousJobsArray.count do --loop through all records
   (     
      if (matchPattern SMTDSettings.PreviousJobsArray[i][1] pattern:("*"+svars.cam.name+"*") do --if the camera name matches
      SMTDSettings.DependencyJobItems[i]=true --set the bit to mark that job as dependency
   )
Borislav "Bobo" Petrov
Product Specialist
Thinkbox Software Inc.

jordiCanela
Posts: 2
Joined: Fri May 12, 2017 8:24 am

Re: Setting dependencies via Maxscript

Postby jordiCanela » Tue May 16, 2017 1:39 pm

Thanks Bobo,

That worked fine. I didn't know that some SMDT.Settings variables where not in use. Are there any resources explaining what the variables and functions available through the SMDT do?

At the moment the only solution I found to scrip for Deadline is to read the extremely long code of the SMDT and online forums, which all seem to be outdated on the dependencies subject.

Thanks again,
Jordi

User avatar
Bobo
Posts: 5865
Joined: Tue Nov 15, 2005 10:26 am
Location: Vancouver, Canada
Contact:

Re: Setting dependencies via Maxscript

Postby Bobo » Tue May 16, 2017 5:16 pm

jordiCanela wrote:Thanks Bobo,

That worked fine. I didn't know that some SMDT.Settings variables where not in use. Are there any resources explaining what the variables and functions available through the SMDT do?

At the moment the only solution I found to scrip for Deadline is to read the extremely long code of the SMDT and online forums, which all seem to be outdated on the dependencies subject.

Thanks again,
Jordi


The SMTD source code is currently the main source of information.

The Dependencies come up a lot here on this forum, I am sure there are a few very up to date posts one could find.
However, I am considering writing more about some of these topics in the near future. At the moment I am rewriting the SMTD docs for the next Deadline release, so I will either add a whole chapter on scripting SMTD, or keep on adding tutorials or blog entries to the Deadline website...
Borislav "Bobo" Petrov
Product Specialist
Thinkbox Software Inc.


Return to “Thinkbox Software - Deadline”

Who is online

Users browsing this forum: No registered users and 2 guests