Skip to content

Instantly share code, notes, and snippets.

@CharlyWargnier
Created March 2, 2020 16:48
Show Gist options
  • Select an option

  • Save CharlyWargnier/baa31095e53a56b22464d59656697a95 to your computer and use it in GitHub Desktop.

Select an option

Save CharlyWargnier/baa31095e53a56b22464d59656697a95 to your computer and use it in GitHub Desktop.
'''
If you have a lengthy training job running on Colab, why bother monitoring it when you can simply send yourself an email when it's finished? This code, credit again to Rohit Midha, can be placed after your training loop, and can send you a message once training has completed. You can likely envision some more creative ways to configure what types of emails are sent for failed tasks, completed tasks, etc, or checkpoint emails for different points along your machine learning pipeline, perhaps.
The code snippet uses the smtplib library which is included by default in your Colab environment. Just fill in the email addresses and passwords (use the same for both in order to send a message to yourself, for example) as well as the message and away you go.
'''
import smtplib
server = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()
server.login("sender_gmail_here@gmail.com", "your_password_here")
msg = "your message to email goes here"
server.sendmail("sender_gmail_here@gmail.com", "receiver_gmail_here@gmail.com", msg)
server.quit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment