AWS Thinkbox Discussion Forums

Custom Email notifications

Hi All,
Is it possible to customize the email notifications, so I can change the content of the message?

I figured out how to set up the messages to come, but I can’t figure out how I can change the content of this notification.

There’s a lot of information in there right now. I need the notification to contain a couple of words.

Example:
“task name” - “Done”
or
“Task name” - “Error”

I think it has been on the cards for a while to customise the email notification, but nothing yet.

I set up an event for onjobcomplete event to email out some info and a preview image through python.

Will you share the finished script?
:slight_smile:

Hi,

Any updates on this topic? Is it possible to customize the email notifications?

Tagging @Justin_B @zainali

Thanks,
Bhavik
Fractal Picture

Hello @Fractal_Admin

Please take a look at this forums reply: Sending one notification email for a group of jobs - #2 by eamsler

Thanks @zainali to point out this, it means we would need to write our own EventPlugin to handle this which will let us build our own custom email subject and body along with the SMTP auth for our email server relay, is that correct?

Thanks,
Bhavik
Fractal Picture

You are very welcome. Yes, that is correct.

1 Like

Thanks for confirming @zainali I am trying to setup the test EventPlugin and added the example snippets from the Creating an Event Plug-in and added HelloFractal.py and HelloFractal.param files in the DeadlineRepository10\custom\events path.

However, when following the Deadline Monitor (Super User Mode) → Tools → Configure Events…

I don’t see the HelloFractal in the list of available EventPlugins. Can you please help identify what I might be missing or the reason for this?

Please let me know if there are any questions.

Attaching the HelloFractal.py and HelloFractal.param files for your perusal.
HelloFractal.py (1.3 KB)
HelloFractal.param.py (735 Bytes) – please rename this, from ‘.param.txt’ to ‘.param’

Also tagging @Justin_B for reference and any thoughts on this.

Thanks,
Bhavik
Fractal Picture

Are these files in DeadlineRepository10\custom\events or DeadlineRepository10\custom\events\HelloFractal? Only the latter is correct.

The event plugin folder needs to have the same name as the .py and .param files.

Yeah! Thanks @Justin_B

My bad did not realize that these files need to reside in the folder name identical to the plugin name! :slight_smile:

With this, I tried submitting a new job and expecting this event to trigger (per the below snippet from HelloFractal.py)

    def OnJobSubmitted(self, job):
        # TODO: Connect to pipeline site to notify it that a job has been submitted
        # for a particular shot or task.
        print('HelloFractal Event-Plugin OnJobSubmitted: ', dir(job))
        pass

and expecting prints on the Deadline Monitor Console but did not see anything! Can you please suggest what is missing here?

Thanks,
Bhavik
Fractal Picture

1 Like

Where’d you submit the job? OnJobSubmitted will be run by the submitting application. So if it was a Monitor submitter then you should see that in the Monitor’s log.

Details on what happens where and when are here in the event plugin docs.

Got it, this submission was using the deadlinecommand and I did not know I would see this in the respective job’s Job Reports

Thanks again for your quick help.

Thanks,
Bhavik
Fractal Picture

1 Like

Hi @Justin_B @zainali,

Is there an OnJobModifyCallback? in case we want to trigger some checks or validations when a given Deadline job is modified?

I couldn’t find that on the Triggering Events page hence the question. And if that’s not a built-in API method, is there a way to do this?

Also on that note, when triggering callbacks, the job object will need to use?

job.JobExtraInfo1='string'

or

job.JobExtraInfo1.set('string')

https://docs.thinkboxsoftware.com/products/deadline/10.2/2_Scripting%20Reference/class_deadline_1_1_jobs_1_1_job.html#properties
image

Because, when trying to use

job.JobExtraInfo1.set('string')

it is resulting in the error:

 HelloFractal: Error setting Job ExtraInfo1 (fp_scene):  'str' object has no attribute 'set'

Whereas, job.JobExtraInfo1='string' is not giving an error but neither seems to be setting the value as expected/intended.

Thanks,
Bhavik
Fractal Picture

Nope, there’s no OnJobModifyCallback, only what’s listed there.

The [get, set] nomenclature refers to the property having getters and setters. Basically meaning you can retrieve the property (getter) and assign the property a value (setter). If there’s no setter for a property on a Job it’ll likely be immutable and something that needs to be set during Job creation.

Be sure you’re running SaveJob() after you’ve made your changes to the Job object.

Thanks for the update @Justin_B, at first I felt SaveJob() would be it, but with the below code snippet:

job.JobExtraInfo1 = scene_name
RepositoryUtils.SaveJob(job)

I still don’t see the expected changes being propagated by the callbacks:

OnJobSubmitted
OnJobSuspended
OnJobResumed

Can you please help confirm if the above code snippet is correct? Or am I missing something?

With the below edits from the GUI, I can validate that the job property JobExtraInfo1 is mutable.

Thanks,
Bhavik
Fractal Picture

:sweat: phew! got it :smiley:

job.set_JobExtraInfo0(scene_name)

Couldn’t find set_JobExtraInfo0() in the docs though.

I mean this as kindly as possible - I didn’t believe you that set_JobExtraInfo0(scene_name) works. So I checked and it does. How’d you come across that? That’s not a function in the codebase, so there’s some oddball stuff with Python for .NET going on here. You don’t need to use it though. And using stuff that’s not in the docs means we can break it without warning so don’t rely on it.

The usual reason that this:

job.JobExtraInfo1 = scene_name
RepositoryUtils.SaveJob(job)

fails to have an effect is if the Job gets saved again later in the script. Keep in mind job is just a copy of the object at the time. and SaveJob pushes the object to the database overwriting what’s currently there.

So order of operations might be playing havoc with you. The rule of thumb is to save the job at the end of your function once you’ve made the changes you want to make. Like in this event example.

Here’s the script I wrote to check both functions:

#run using "%deadline_path%"\deadlinecommand -executescript test.py
from Deadline.Scripting import RepositoryUtils

def __main__():
    job = RepositoryUtils.GetJob("6435e5077a5a910c5cf6b3c6", True)
    job.JobExtraInfo1 = "I've been set in a script!"

    job.set_JobExtraInfo0("I should not be!")

    RepositoryUtils.SaveJob(job)

:magic_wand: :smiley:

If my memory serves me right that was the dir dump of job object.

pprint(dir(job))

attaching dir_jobObject.zip (3.8 KB) the dump for your reference.

Sure, I am on the same page and would prefer to stick to the recommended and supported API methods only. And that’s why I tried searching for set_ method in the docs which I couldn’t find. And at first, I was not using this method until I ran out of options, as you see in my previous posts in this thread.

Noted, and thanks for the example snippet we will keep in mind that we save/overwrite the job object as frequently as possible. However, what-if, there are different callback (events) and therefore it might demand saving the job object at different time intervals, is that okay to do?

In the sense, saving the job object for the suspend, fail, and resume events and not all at once.

As for using this syntax for property update, I am sure I tried this job.JobExtraInfo1 where save job was used for one only and since I did not get success with that I tried/tested with job.set_JobExtraInfo1(fp_scene) which worked. Attaching HelloFractal.py my WIP test event plugin script for your reference and perusal. @Justin_B

Thanks,
Bhavik
Fractal Picture

1 Like

The event scripts don’t get run in parallel, so long as you save your work by the end of your script you’ll be in good shape.

Looked at your HelloFractal.py and it all appears fine. I swapped out the set_* calls with the usual way of doing things, and called the OnJobSubmitted in a __main__() to make testing easier and it worked great on my machine. My guess would be that the Workers were relying on a cached copy of your script that didn’t have the call to SaveJob? I highly recommend this method of development, it lets you circumnavigate the whole caching system and saves a pile of pain.

HelloFractal.py (8.5 KB)

Privacy | Site terms | Cookie preferences