AWS Thinkbox Discussion Forums

Run post jobs script for any jobs by default

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

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:
    github.com/ThinkboxSoftware/Dea … Timeout.py

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

[code]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 )[/code]
  1. 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:

docs.thinkboxsoftware.com/produc … 2dbe6f2fb4

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

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

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

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 !

Privacy | Site terms | Cookie preferences