Python job submission doesnt run __main__ function

Hi :slight_smile:

I am just starting with python and just trying to understand how to submit a proper job that uses the added arguments (the current rendering frame) but this already fails for somehow.

What I do:

  • I submit with the DL-monitor a python job.
  • I add the Arguments < STARTFRAME > < ENDFRAME >
  • Frame List -> 1-4

The python job contains this code:

 def __main__ ( *args ):
      with open( "X:/DL_test.txt", "w" ) as f:
           f.write( "Frame: " + str( args[0] ) )

When the job is completed the function main didn’t actually run.
If I submit a python file without the main function the code does work and a txt is created but I can not use the arguments.

From the Job info parameters it refers to the plugin=Python.

What do I miss here and how do I let Deadline to run the main function that passes the *args?

Help would be really appreciated :slight_smile: Thanks

__main__ is only automatically call if it’s part of a class. Python jobs in this case are normal Python scripts. So you can either do the whole thing without def, or call the def manually at the end.

1 Like

Thanks! That does make sense. But if I call the def manually I also have to put manually the arguments which I do not know.

So in other words, How do I get the current taskID Deadline is working on?

In the manual it shows like:

import re
from System.IO import *
from Deadline.Scripting import *

def __main__( *args ):

or

import re
from System.IO import *
from Deadline.Scripting import *

def __main__( jobID, taskIDs=None ):

Both relying on the def main, which in both examples are not part of a class and not runned manually at the end.

Shoudn’t be to hard I guess but I simply can’t get it to work yet :thinking:

The manual I refer to:
https://docs.thinkboxsoftware.com/products/deadline/10.0/1_User%20Manual/manual/job-scripts.html

That is when the script is run as part of Deadline eco-system (sorry I don’t know a better term for this). Those are executed as part of other task so it has access to all Deadline classes and objects.

For example, in these 2 scripts here I can do

from Deadline.Scripting import *
def __main__( deadlinePlugin, *args ):
	job = deadlinePlugin.GetJob()

However for stand-alone script I don’t thnk you have access to that, as mentioned above, they’re normal Python script with no relation to Deadline. You can use stand-alone API to query info from Deadline but the ID will have to be passed manually.

https://docs.thinkboxsoftware.com/products/deadline/10.0/1_User%20Manual/manual/standalone-python.html

1 Like

Awesome! Thank you so much for this reply :slight_smile: ! This really clear things up for me!