AWS Thinkbox Discussion Forums

Post Job Error with Sample.py

Hi guys,

I wanted to test the Sample.py as a Post-Job-Script. I Inserted the Script via the Monitor and refered to the script in the repository. Unfortunaly I recieved this Error by rendering the job.

Basically the script(Sample.py) is the following:
def main():
‘’’ This is run by Deadline before or after a task depending on which context its used in ‘’’

LogInfo("Script ran.")
LogInfo("...And did absolutely nothing")

It throws the folloing Error:

Post job script “X:/custom/scripts/Jobs/Sample.py”: TypeError : main() takes no arguments (2 given) (FranticX.Scripting.PythonNetException)
at Python.Runtime.PyObject.Invoke(PyObject[] args)
at Python.Runtime.PyObject.InvokeMethod(String name, PyObject[] args)
at FranticX.Scripting.PythonNetScriptEngine.CallFunction(String moduleName, String functionName, Object[] args)
at Deadline.Plugins.PluginWrapper.RenderScript(String scriptFilename, Boolean preJobScript, String& outMessage, AbortLevel& abortLevel)

=======================================================
Type

RenderPluginException

Does someone know the reason of this Error ?

As the error tells you, Deadline passes two arguments to the function, but you expect none, so it fails.
It sounds a bit counter-intuitive, as you could think “but I am asking for no arguments, why is it telling me about two of them?” It is because the function is invoked by Deadline which passes the two arguments, and catches an error because your function’s arguments list (0 expected) and the actual argument list passed by Deadline misalign.

Here is the documentation of Job Scripts

Note that different types of scripts are called with different parameter lists. For example a Job Script (one executed in place of rendering) only gets the DeadlinePlugin as argument. A Dependency Script expects two - the JobID and TaskIDs. In your case, a Post Job script gets the Deadline Plugin, and the type of the script (“post job”) as argument.

I submitted this simple script as Post Job script:

def __main__( *args ):
    print (args[0])
    print (args[1])
    True

The result in the Post Job’s Log was:

2020-12-21 10:49:49:  0: INFO: Executing post job script 'C:\Users\bobop\Documents\3dsMax\scripts\postjobtest.py'
2020-12-21 10:49:49:  0: PYTHON: Deadline.Plugins.DeadlinePlugin
2020-12-21 10:49:49:  0: PYTHON: post job
2020-12-21 10:49:49:  0: Done executing plugin command of type 'Execute Script'

So you can use the first argument to access the DeadlinePlugin, and the second argument to reason about the type of the script (pre job, post job, pre task, post task)…

For the fun of it, I assigned the same script above as all 4 types of scripts, and as expected I got the following output in the various logs:

Pre-Job Script Log:

2020-12-21 10:57:00:  0: INFO: Executing pre job script 'C:\Users\bobop\Documents\3dsMax\scripts\postjobtest.py'
2020-12-21 10:57:00:  0: PYTHON: Deadline.Plugins.DeadlinePlugin
2020-12-21 10:57:00:  0: PYTHON: pre job

Task 0 Log:

...
2020-12-21 10:58:14:  0: Done executing plugin command of type 'Start Job'
2020-12-21 10:58:14:  0: Plugin rendering frame(s): 0
2020-12-21 10:58:14:  0: Executing plugin command of type 'Render Task'
2020-12-21 10:58:14:  0: INFO: Executing pre task script 'C:\Users\bobop\Documents\3dsMax\scripts\postjobtest.py'
2020-12-21 10:58:14:  0: PYTHON: Deadline.Plugins.DeadlinePlugin
2020-12-21 10:58:14:  0: PYTHON: pre task
...
2020-12-21 10:58:15:  0: INFO: Executing post task script     'C:\Users\bobop\Documents\3dsMax\scripts\postjobtest.py'
2020-12-21 10:58:15:  0: PYTHON: Deadline.Plugins.DeadlinePlugin
2020-12-21 10:58:15:  0: PYTHON: post task
2020-12-21 10:58:15:  0: Done executing plugin command of type 'Render Task'

Job-Post Script (we saw this already)

2020-12-21 10:58:31:  0: INFO: Executing post job script 'C:\Users\bobop\Documents\3dsMax\scripts\postjobtest.py'
2020-12-21 10:58:31:  0: PYTHON: Deadline.Plugins.DeadlinePlugin
2020-12-21 10:58:31:  0: PYTHON: post job
2020-12-21 10:58:31:  0: Done executing plugin command of type 'Execute Script'
1 Like

Thank you so much this was so helpful.

Privacy | Site terms | Cookie preferences