[Weekend Heck] Sending IPhone notification from IPython Notebook when the cell execution is done.

IPython Notebook has a useful notification feature that notifies when the kernel is sitting idle i.e. all the cell execution is finished. Recently, however, I was working on a long running python code. Most likely when the cell execution finishes I won’t be near my computer. Hence I thought of writing a magic function that can send me a message on my phone once the cell execution is done. Using some apple script heck and limiting to MacBook and iPhone, writing this phone notification magic function turned out to be pretty simple. You can find it over here.

Below is an example of how to use “phone_notification” magic function. Once the cell execution is completed, it will send an iMessage to your iPhone indicating whether the job completed successfully or if it failed. If the job failed, it will send an error message in the iMessage. You can find a sample notebook of how to use this magic function within the IPython Notebook over here).

%%phone_notification -p 1XXXXXXXXXX -m "Test Job Done"
import time
time.sleep(1)
print "done"

Note that the magic function will only work if you are using MacBook and have an iPhone. However, it should be pretty easy to adopt for Android ecosystem. I hope you will enjoy the phone notification. Let me know what you think about it.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s