MayaBatch and error handling

Discussion and Support of Deadline, the Render Management System
lonniek
Posts: 7
Joined: Tue Jan 24, 2017 12:37 pm

MayaBatch and error handling

Postby lonniek » Sun Sep 10, 2017 2:39 am

Greetings,

I am running maya script jobs through deadline and I would like it to stop on errors. I see the HandleErrorMessage() where you are containing specific errors.

I'd like to be able to raise a StandardError in the script and have it stop for example. ANyway to make that possible without having to write a new plugin?

lonnie

eamsler
Posts: 1827
Joined: Thu Dec 16, 2010 1:02 pm
Location: Winnipeg, MB, Canada

Re: MayaBatch and error handling

Postby eamsler » Mon Sep 11, 2017 11:25 am

I'd say copy the existing plugin into "[repo]\custom\plugins" and add that handler for yourself. You could also print something that would match the existing errors, but that might be a little strange.

It looks like you could say: "Error: FatalError: StandardError: My snazzy text". That would catch via this code here:

Code: Select all

        self.AddStdoutHandlerCallback( ".*Error: .*|.*Warning: .*" ).HandleCallback += self.HandleErrorMessage
       
        # ...some lines...
       
        def HandleErrorMessage( self ):
        # ...yet more lines ...
            elif( errorMessage.find( "Fatal Error:" ) != -1 ):
                ignoreError = False


If the user unchecked the strict error checking though, your custom text wouldn't fail the job.
Edwin Amsler
Head of Support
Thinkbox Software Inc
+1-866-419-0283 ext 804

Winnipeg

kwatts
Posts: 51
Joined: Tue Mar 01, 2016 10:34 am

Re: MayaBatch and error handling

Postby kwatts » Mon Sep 11, 2017 11:33 am

*edit: was typing at the same type as edwin... we are saying the same thing ;)

you can always add your own error or exception types to an existing plugin.
i would recommend copying the whole plugin to the entire plugin folder to \repo\custom\plugins .
that way you have a clean copy of the original. (this helps if your upgrading to a new deadline version.)

example from our mayabatch plugin:

Code: Select all

# add lines that we want to error, and redirect them to an existing handler:
# catch redshift no render layers: issue 683
self.AddStdoutHandlerCallback(".*No render layers are marked as renderable.  Render aborted.*").HandleCallback += self.HandleFatalError

#  catch no renderable cameras that causes redshift to not render adn mark the frame as done, issue:754
self.AddStdoutHandlerCallback(".*No renderable cameras found.  Aborting render.*").HandleCallback += self.HandleFatalError

# We want to collect all the crash data in to packages per job, in case we need to forward to a vendor, push to a custom error handler.
#  catch maya crashes in a generic error type.
self.AddStdoutHandlerCallback(".*Writing crash report.*").HandleCallback += self.HandleCrashReport
#  sometimes it exits before the writing crash dump, and it dies with a seg fault.
self.AddStdoutHandlerCallback(".*Segmentation fault.*").HandleCallback += self.HandleCrashReport



Hope this helps.
Kym

lonniek
Posts: 7
Joined: Tue Jan 24, 2017 12:37 pm

Re: MayaBatch and error handling

Postby lonniek » Mon Sep 11, 2017 4:34 pm

Thanks both of you, makes complete sense. Just wasn't sure if there were hooks elsewhere.

Will give it a go

Lonnie

lonniek
Posts: 7
Joined: Tue Jan 24, 2017 12:37 pm

Re: MayaBatch and error handling

Postby lonniek » Mon Sep 11, 2017 11:44 pm

Ok, this works though I think what I want is slightly different.

Tell me if what I am trying makes sense. I am using MayaBatch though I don't have a maya scene as I am completely generating the scene on "the wall". I am managing dependencies and launching a series of jobs through the api Jobs().SubmitJob(). Each job runs a python script that assembles a maya scene and saves it out. Based on the suggestions in this thread I opened up the error handling and it is working. It is not stopping the job. I would like it to stop the job so that the script can be 'fixed' and task retries.

Is there a way to fail a maya job in deadline so the task can be retried?

Before deadline I was managing maya standalone. Should I run a python job and run maya standalone myself? Or is MayaBatch still the best way to achieve what I want?

(on a side note I am feeding the MayaBatch plugin a garbage maya file as it seems to need a file to do anything, which makes me think maybe that isn't plugin I should use.)

kwatts
Posts: 51
Joined: Tue Mar 01, 2016 10:34 am

Re: MayaBatch and error handling

Postby kwatts » Tue Sep 12, 2017 10:30 am

We do this.

We had to modify the plugin, so that you could have a mel/python script without needing to have a maya scene that existed.
In a nutshell, in the plugin where it starts to build the global mel script, there is a point there where it checks to see if there is a maya scene file to load.

we set it up, so if there is no given scenefile, it adds the following lines to the mel script, so that the mel/python script runs on a new maya scene:

Code: Select all

if self.SceneFile:
    # load the scene file, use the CreateDelayLoadSceneMelscript etc...
else:
    # no maya scene, make sure maya has a clean scene, incase we are sharing a session.
    scriptBuilder.AppendLine()
    scriptBuilder.AppendLine( 'file -f -new;' )
    scriptBuilder.AppendLine( 'print ("Creating a new blank scene in maya.\\n");' )
    scriptBuilder.AppendLine()


Let me know if you need more info.

Cheers
Kym

lonniek
Posts: 7
Joined: Tue Jan 24, 2017 12:37 pm

Re: MayaBatch and error handling

Postby lonniek » Tue Sep 12, 2017 11:34 pm

Thanks heaps!

the if SceneFile thing worked great. Though it was returning the python file if I didn't send a .ma. Easy to check for.

And I just discovered OverrideTaskFailureDetection. Along with the HandleError message gives me the control I need for this specific task.

Really appreciate help and quick response.

Cheers,
lonnie

eamsler
Posts: 1827
Joined: Thu Dec 16, 2010 1:02 pm
Location: Winnipeg, MB, Canada

Re: MayaBatch and error handling

Postby eamsler » Wed Sep 13, 2017 10:29 am

Welcome sir! Also, thanks Kym!
Edwin Amsler
Head of Support
Thinkbox Software Inc
+1-866-419-0283 ext 804

Winnipeg


Return to “Thinkbox Software - Deadline”

Who is online

Users browsing this forum: No registered users and 1 guest