In this post we look at how to send notifications using Vigil from jupyter notebooks. This is an extension of this previous post. There is also an excellent jupyter extension for push notifications in your browser as cells finish executing, but this post is an alternative method that sends you a text or email, and can also work independent of jupyter notebooks; if you are working in Google Colab for example.

See the aforementioned post on Vigil for more background on the tool. It is a free tool that wraps a shell command, and emails/texts us when the process has completed, along with the status and execution time. This is very useful when training ML models, as this can be very time consuming. Vigil also takes the following flags in order to simply report a status (rather than wrapping the command itself):

  • --report/-r (only report status, don't wrap and execute a command)
  • --command/-c (command text being reported on)
  • --status/-s (exit status text of command being reported on)
  • --duration/-d (duration of command being reported on)
Thus, as in the example below, we can execute code in python in a jupyter cell, and then pass the command title, status and duration to Vigil to report to us that the cell has finished execution.

! wget -O vigil && chmod +x vigil
   start_time = time.time()
   # our actual code, y_train)
   # our actual code
except Exception as ex:
   status = 'failure: ' + str(ex)
duration = str(round(time.time() - start_time, 3)) + 's'
! VIGIL_USERNAME= VIGIL_TOKEN=<******> ./vigil -r -c 'hyperparam search' \
-s '$status' -d '$duration'