A Jupyter Notebook %%magic for Browser Notifications of Cell Completion
Project description
This package provides a Jupyter notebook cell magic %%notify that notifies the user upon completion of a potentially long-running cell via a browser push notification. Use cases include long-running machine learning models, grid searches, or Spark computations. This magic allows you to navigate away to other work (or even another Mac desktop entirely) and still get a notification when your cell completes.
Supported browsers
The extension has currently been tested in Chrome (Version: 58.0.3029) and Firefox (Version: 53.0.3).
Note: Firefox also makes an audible bell sound when the notification fires (the sound can be turned off in OS X as described here).
Import the repo
To use the package, install it via pip directly:
pip install jupyternotify
or add it to the requirements.txt of your repo.
To install directly from source:
git clone git@github.com:ShopRunner/jupyter-notify.git
cd jupyter-notify/
virtualenv venv
source venv/bin/activate
pip install -r requirements.txt
jupyter notebook
Usage
Load inside a Jupyter notebook:
import jupyternotify
ip = get_ipython()
ip.register_magics(jupyternotify.JupyterNotifyMagics)
Automatically load in all notebooks
Add the following lines to your ipython startup file:
c.InteractiveShellApp.exec_lines = [ 'import jupyternotify', 'ip = get_ipython()', 'ip.register_magics(jupyternotify.JupyterNotifyMagics)' ]
The .ipython startup file can be generated with ipython profile create [profilename] and will create a configuration file at ~/.ipython/profile_[profilename]/ipython_config.py'. Leaving [profilename] blank will create a default profile (see this for more info).
To test the extension, try
%%notify import time time.sleep(5)
Options
You may specify options while loading the magic:
import jupyternotify
ip = get_ipython()
ip.register_magics(jupyternotify.JupyterNotifyMagics(
ip,
option_name="option_value"
))
The following options exist: - require_interaction - Boolean, default False. When this is true, notifications will remain on screen until dismissed. This feature is currently only available in Google Chrome.
## Custom Message
You may specify what message you wish the notification to display:
%%notify -m "sleep for 5 secs" import time time.sleep(5)
License
Copyright (c) 2017, ShopRunner
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.