Skip to content

Commit

Permalink
Bumped the version, filled out the CHANGELOG, and added a test notebo…
Browse files Browse the repository at this point in the history
…ok (#24)

* Bumped the version, filled out the CHANGELOG, and added a test notebook.

* Fix a typo.
  • Loading branch information
mdagost authored Nov 3, 2017
1 parent 6dd1e3b commit 8e5dd1d
Show file tree
Hide file tree
Showing 5 changed files with 344 additions and 2 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).

## [0.1.13] - 2017-11-03
### Added
- Added line magic %notify to trigger notifications mid-cell (from @bensteers)
- Added %autonotify line magic to automatically notify after a certain length of time threshold (from @bensteers)
- Added --output/-o option to use cell output as message (from @bensteers)
- Added a jupyter notebook to run through the tests specified in the README

## [0.1.12] - 2017-09-25
### Added
- Added some badges to the README and PyPI

## [0.1.11] - 2017-08-25
### Fixed
- Fixed a small formatting typo in the README
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ time.sleep(5)

## Fire notification mid-cell

You may fire a notification using line magic.
You may also fire a notification in the middle of a cell using line magic.

```python
import time
Expand Down
100 changes: 100 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
|pypiv| |pyv| |License| |Thanks|

A Jupyter Magic For Browser Notifications of Cell Completion
============================================================

Expand Down Expand Up @@ -79,3 +81,101 @@ To test the extension, try
%%notify
import time
time.sleep(5)

Options
-------

You may specify options while loading the magic:

.. code:: python
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:

.. code:: python
%%notify -m "sleep for 5 secs"
import time
time.sleep(5)
Fire notification mid-cell
--------------------------

You may also fire a notification in the middle of a cell using line
magic.

.. code:: python
import time
time.sleep(5)
%notify -m "slept for 5 seconds."
time.sleep(6)
%notify -m "slept for 6 seconds."
time.sleep(2)
Automatically trigger notification after a certain cell execution time
----------------------------------------------------------------------

Using the ``autonotify`` line magic, you can have notifications
automatically trigger on **cell finish** if the execution time is longer
than some threshold (in seconds) using ``%autonotify --after <seconds>``
or ``%autonotify -a <seconds>``.

.. code:: python
import numpy as np
import time
# autonotify on completion for cells that run longer than 30 seconds
%autonotify -a 30
Then later...

.. code:: python
# no notification
time.sleep(29)
.. code:: python
# sends notification on finish
time.sleep(31)
``autonotify`` also takes the arguments ``--message`` / ``-m`` and
``--output`` / ``-o``.

Use cell output as message
--------------------------

You may use the last line of the cell's output as the notification
message using ``--output`` or ``-o``.

.. code:: python
%%notify -o
answer = 42
'The answer is {}.'.format(answer)
Notification message: The answer is 42.

.. |pypiv| image:: https://img.shields.io/pypi/v/jupyternotify.svg
:target: https://pypi.python.org/pypi/jupyternotify
.. |pyv| image:: https://img.shields.io/pypi/pyversions/jupyternotify.svg
:target: https://pypi.python.org/pypi/jupyternotify
.. |License| image:: https://img.shields.io/pypi/l/jupyternotify.svg
:target: https://github.com/ShopRunner/jupyter-notify/blob/master/LICENSE.txt
.. |Thanks| image:: https://img.shields.io/badge/Say%20Thanks-!-1EAEDB.svg
:target: https://saythanks.io/to/mdagost
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

setup(
name='jupyternotify',
version='0.1.12',
version='0.1.13',
description='A Jupyter Notebook %%magic for Browser Notifications of Cell Completion',
long_description=readme+'\n\n'+authors+'\nLicense\n-------\n'+license,
author='Michelangelo D\'Agostino',
Expand Down
231 changes: 231 additions & 0 deletions tests/test_notebook.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,231 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## `jupyter-notify` Test Notebook"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Test the basic functionality:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import jupyternotify\n",
"ip = get_ipython()\n",
"ip.register_magics(jupyternotify.JupyterNotifyMagics)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%%notify\n",
"import time\n",
"time.sleep(5)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Test the `require_interaction` option for stickiness:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import jupyternotify\n",
"ip = get_ipython()\n",
"ip.register_magics(jupyternotify.JupyterNotifyMagics(\n",
" ip,\n",
" require_interaction=True\n",
"))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%%notify\n",
"import time\n",
"time.sleep(5)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Test custom messages:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import jupyternotify\n",
"ip = get_ipython()\n",
"ip.register_magics(jupyternotify.JupyterNotifyMagics)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%%notify -m \"Slept for 5 seconds.\"\n",
"import time\n",
"time.sleep(5)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Test the mid-cell line magic:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import time\n",
"time.sleep(5)\n",
"%notify -m \"Slept for 5 seconds.\"\n",
"time.sleep(6)\n",
"%notify -m \"Slept for 6 seconds.\"\n",
"time.sleep(2)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Test the autonotify line magic:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import numpy as np\n",
"import time\n",
"# autonotify on completion for cells that run longer than 30 seconds\n",
"%autonotify -a 30"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# no notification\n",
"time.sleep(29)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# sends notification on finish\n",
"time.sleep(31)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Test the option to use the last line of cell output as the message:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%%notify -o\n",
"answer = 42\n",
"'The answer is {}.'.format(answer)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.1"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

0 comments on commit 8e5dd1d

Please sign in to comment.