Configuring job start/end email in OOD 1.3


#1

We had hacked in the ability for users to get an email when their job starts when we first installed OnDemand 1.1. We just upgraded to 1.3 and see that there is now both email address and the ability to get an email when the job terminates. We did not port any of our changes to version 1.3 and wanted to use those options that are built in instead. I must be missing something though as these don’t seem to be working. I’ve added bc_email and bc_email_on_terminate to my form but the info doesn’t make it to my job script (we’re running SLURM). They are, however, found in the user_defined_context.json file. Also, instead of the Boolean it is configured as, when I add bc_email_on_terminate to the form it shows up as a text box.

Any suggestions?

Source: Originally posted by Dori Sajdak in the ood-users mailing list.


#2

The “bc_email_on_started” is a “built in” attribute but unfortunately the only built in ones we created right now are:

bc_account
bc_email_on_started
bc_num_hours
bc_num_slots
bc_queue
bc_vnc_idle
bc_vnc_resolution

Notice, missing are bc_email and bc_email_on_terminate. Based on your description I think you want a text field for the user to enter the email address, and a checkbox to check if they want to receive an email when the job stops.

Solution 1:

You can do this by modifying your form.yml.erb and submit.yml.erb like this (merging the below with the rest of the form, attributes and script sections in whatever interactive app you have):

form.yml.erb

form:
  - email
  - email_on_terminated
attributes:
  email:
    label: "Email address"
    help: "Email address if you want to receive emails different from the default"
  email_on_terminated
    widget: check_box
    label: "Receive email when job terminates"
    help: "If checked you will receive an email when the job terminates"

submit.yml.erb

script:
  email_on_terminated: <%= ! email_on_terminated.to_i.zero? %>
  <% unless email.blank? %>
  email: <%= email %>
  <% end %>

Solution 2:

Or if you want to just show an email address and if the user provides one send an email on terminated you could do this:

form.yml.erb

form:
  - email
attributes:
  email:
    label: "Email address"
    help: "Enter email address if you want to receive email when job terminates"

submit.yml.erb

script:
  email_on_terminated: <%= ! email_on_terminated.to_i.zero? %>
  <% unless email.blank? %>
  email: <%= email %>
  email_on_terminated: true
  <% end %>

The hash defined as a value for the script key in submit.yml.erb is used as an argument to construct an instance of this class https://github.com/OSC/ood_core/blob/d21a1d62a41b1a3e6d05a28cfe1100bb931597f9/lib/ood_core/job/script.rb. So that is where I verified I could set “email_on_terminated”.

This describes more details of how you can customize the form.yml.erb attributes: https://osc.github.io/ood-documentation/master/app-development/interactive/form.html#attributes. In OOD 1.4 this will become a little more flexible to work with.