Run post jobs script for any jobs by default

Discussion and Support of Deadline, the Render Management System
chris@megalis.com
Posts: 12
Joined: Mon May 15, 2017 4:59 am

Run post jobs script for any jobs by default

Postby chris@megalis.com » Fri May 19, 2017 2:06 am

Hi,

we are building some tools so Deadline can give us jobs details through private messages when it is done or and error occurs (and probably much more options later so only using ). There is no problem running our tests using the Job properties / Scripts then post jobs but currently we have to set the script ourself for each job.

Even if we could probably set it when we run the job, we would like that no matter the type of job, there is a default post job script to run. This way we don't have to add those commands each time we use a new tool in our pipeline.

I could not find where this can be set as default, is it possible ?

Thanks
Chris

User avatar
MikeOwen
Posts: 3512
Joined: Thu Jul 19, 2007 5:00 am
Location: London, UK
Contact:

Re: Run post jobs script for any jobs by default

Postby MikeOwen » Fri May 19, 2017 6:01 am

An event plugin could be used here. Couple of options:

1. Write an event plugin for "onJobSubmitted" so when a job is submitted, it has auto assigned a post job script. This would be similar to this event plugin here:
https://github.com/ThinkboxSoftware/Dea ... Timeout.py

except it would look like this (oops, I just wrote it!)

Code: Select all

from Deadline.Events import *
from Deadline.Scripting import *

def GetDeadlineEventListener():
    return SetJobPostJobScript()

def CleanupDeadlineEventListener( eventListener ):
    eventListener.Cleanup()

class SetJobPostJobScript( DeadlineEventListener ):
    def __init__( self ):
        self.OnJobSubmittedCallback += self.OnJobSubmitted
   
    def Cleanup( self ):
        del self.OnJobSubmittedCallback

    def OnJobSubmitted( self, job ):
        scriptFilename = "/network/path/to/scriptFilename.py"
        RepositoryUtils.SetPostJobScript( job, scriptFilename )


2. Alternatively, why not just execute your script directly in an event plugin when "onJobFinished" callback occurs? Various process utils are here or you can use subprocess, etc:

http://docs.thinkboxsoftware.com/produc ... 2dbe6f2fb4
Mike Owen
Solutions Architect
Thinkbox / AWS

chris@megalis.com
Posts: 12
Joined: Mon May 15, 2017 4:59 am

Re: Run post jobs script for any jobs by default

Postby chris@megalis.com » Fri May 19, 2017 9:36 am

Thanks so much for your quick answer Mike, this is gonna be of a great help !

chris@megalis.com
Posts: 12
Joined: Mon May 15, 2017 4:59 am

Re: Run post jobs script for any jobs by default

Postby chris@megalis.com » Wed May 24, 2017 7:51 am

Hi again,

I got something nice to work for one event, however it seems like with the code below, once one event as occurred, the rest gets cleared out.
So for example, I get the OnJobRequeued event but nothing else after. I suppose the cleanup happens right after the OnJobRequeued event but I wonder what I should do to have all events in use and still the cleaning occurring properly to avoid memory leaks.

Thanks
Chris

Code: Select all

from System.Diagnostics import *
from System.IO import *

from Deadline.Events import *
from Deadline.Scripting import *

def GetDeadlineEventListener():
    return EventListener()

def CleanupDeadlineEventListener( deadlinePlugin ):
    deadlinePlugin.Cleanup()

class EventListener (DeadlineEventListener):
    def __init__( self ):
        self.OnJobSubmittedCallback += self.OnJobSubmitted
        self.OnJobStartedCallback += self.OnJobStarted
        self.OnJobFinishedCallback += self.OnJobFinished
        self.OnJobRequeuedCallback += self.OnJobRequeued
        self.OnJobFailedCallback += self.OnJobFailed

    def Cleanup( self ):
        del self.OnJobSubmittedCallback
        del self.OnJobStartedCallback
        del self.OnJobFinishedCallback
        del self.OnJobRequeuedCallback
        del self.OnJobFailedCallback

    def OnJobSubmitted(self, job):
        pass
       
    def OnJobStarted(self, job):
        pass

    def OnJobFinished(self, job):
        pass

    def OnJobRequeued(self, job):
        pass
       
    def OnJobFailed(self, job):
        pass

chris@megalis.com
Posts: 12
Joined: Mon May 15, 2017 4:59 am

Re: Run post jobs script for any jobs by default

Postby chris@megalis.com » Wed May 24, 2017 8:00 am

My apology, it seems like changing from deadlinePlugin (like some example i found) to your example made it work. I didn't expect that.

It works great now !
Thanks for your help again !


Return to “Thinkbox Software - Deadline”

Who is online

Users browsing this forum: No registered users and 1 guest