{"id":22017840,"url":"https://github.com/shoprunner/jupyter-notify","last_synced_at":"2025-05-16T13:02:03.152Z","repository":{"id":52499529,"uuid":"93064132","full_name":"ShopRunner/jupyter-notify","owner":"ShopRunner","description":"A Jupyter Notebook magic for browser notifications of cell completion","archived":false,"fork":false,"pushed_at":"2022-08-09T17:30:42.000Z","size":43,"stargazers_count":580,"open_issues_count":16,"forks_count":40,"subscribers_count":71,"default_branch":"main","last_synced_at":"2025-05-10T10:48:09.772Z","etag":null,"topics":["datascience"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ShopRunner.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-06-01T14:08:55.000Z","updated_at":"2025-02-23T00:24:19.000Z","dependencies_parsed_at":"2022-08-13T02:00:57.487Z","dependency_job_id":null,"html_url":"https://github.com/ShopRunner/jupyter-notify","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShopRunner%2Fjupyter-notify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShopRunner%2Fjupyter-notify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShopRunner%2Fjupyter-notify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShopRunner%2Fjupyter-notify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ShopRunner","download_url":"https://codeload.github.com/ShopRunner/jupyter-notify/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254535787,"owners_count":22087394,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["datascience"],"created_at":"2024-11-30T05:08:21.145Z","updated_at":"2025-05-16T13:02:03.087Z","avatar_url":"https://github.com/ShopRunner.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![pypiv](https://img.shields.io/pypi/v/jupyternotify.svg)](https://pypi.python.org/pypi/jupyternotify)\n[![pyv](https://img.shields.io/pypi/pyversions/jupyternotify.svg)](https://pypi.python.org/pypi/jupyternotify)\n[![License](https://img.shields.io/pypi/l/jupyternotify.svg)](https://github.com/ShopRunner/jupyter-notify/blob/main/LICENSE.txt)\n[![Thanks](https://img.shields.io/badge/Say%20Thanks-!-1EAEDB.svg)](https://saythanks.io/to/mdagost)\n\n\u003cimg src=\"https://s3.amazonaws.com/shoprunner-github-logo/shoprunner-logo.svg\" alt=\"ShopRunner logo\" width=\"300\"/\u003e\n\n# A Jupyter Magic For Browser Notifications of Cell Completion\n\n\u003cimg src=\"https://s3.amazonaws.com/shoprunner-github-logo/jupyter_chrome.png\" alt=\"Jupyter notebook notification in Chrome\" width=\"750\"/\u003e\n\u003cimg src=\"https://s3.amazonaws.com/shoprunner-github-logo/jupyter_firefox.png\" alt=\"Jupyter notebook notification in Firefox\" width=\"750\"/\u003e\n\nThis 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.  Clicking on the body of the notification will bring you directly to the browser window and tab with the notebook, even if you're on a different desktop (clicking the \"Close\" button in the notification will keep you where you are).\n\n### Supported browsers\nThe extension has currently been tested in Chrome (Version:  58.0.3029) and Firefox (Version: 53.0.3). \n\n**Note**: Firefox also makes an audible bell sound when the notification fires (the sound can be turned off in OS X as described [here](https://stackoverflow.com/questions/27491672/disable-default-alert-sound-for-firefox-web-notifications)).\n\n**Note for Remote Servers**: This extension will work on remote servers as well.  However, you'll need to have the jupyter notebook running on https. You can find instructions [here](https://jupyter-notebook.readthedocs.io/en/stable/public_server.html).\n\n## Import the repo\nTo use the package, install it via pip directly:\n\n```\npip install jupyternotify\n```\n\nor add it to the requirements.txt of your repo.\n\nTo install directly from source:\n\n``` bash\ngit clone git@github.com:ShopRunner/jupyter-notify.git\ncd jupyter-notify/\nvirtualenv venv\nsource venv/bin/activate\npip install -r requirements.txt\njupyter notebook\n```\n\n## Usage\n### Load inside a Jupyter notebook:\n``` python\n%load_ext jupyternotify\n```\n\n### Automatically load in all notebooks\nAdd the following lines to your ipython startup file:\n```\nc.InteractiveShellApp.extensions = [\n    'jupyternotify'\n]\n```\nThe .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](http://ipython.org/ipython-doc/dev/config/intro.html) for more info).\n\nTo test the extension, try\n\n```\n%%notify\nimport time\ntime.sleep(5)\n```\n\n## Options\n\nNOTE: Currently options cannot be used with `%load_ext` or the ipython startup file instructions above. \n\nTo load the magic with options, you should load it manually by doing the following:\n\n```python\nimport jupyternotify\nip = get_ipython()\nip.register_magics(jupyternotify.JupyterNotifyMagics(\n    ip,\n    option_name=\"option_value\"\n))\n```\n\nor add this to your ipython startup file:\n\n```python\nc.InteractiveShellApp.exec_lines = [\n    'import jupyternotify',\n    'ip = get_ipython()',\n    'ip.register_magics(jupyternotify.JupyterNotifyMagics(ip, option_name=\"option_value\"))'\n]\n```\n\nThe following options exist:\n- `require_interaction` - Boolean, default False. When this is true,\n  notifications will remain on screen until dismissed. This feature is currently\n  only available in Google Chrome.\n\n\n## Custom Message\n\nYou may specify what message you wish the notification to display:\n\n```python\n%%notify -m \"sleep for 5 secs\"\nimport time\ntime.sleep(5)\n```\n\n\u003cimg src=\"https://s3.amazonaws.com/shoprunner-github-logo/jupyter_custom_message.png\" alt=\"Jupyter notebook notification with custom message\" width=\"750\"/\u003e\n\n## Fire notification mid-cell\n\nYou may also fire a notification in the middle of a cell using line magic.\n\n```python\nimport time\ntime.sleep(5)\n%notify -m \"slept for 5 seconds.\"\ntime.sleep(6)\n%notify -m \"slept for 6 seconds.\"\ntime.sleep(2)\n```\n\n\n## Automatically trigger notification after a certain cell execution time\n\nUsing 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 \u003cseconds\u003e` or `%autonotify -a \u003cseconds\u003e`. \n\n```python\nimport numpy as np\nimport time\n# autonotify on completion for cells that run longer than 30 seconds\n%autonotify -a 30\n```\n\nThen later...\n\n```python\n# no notification\ntime.sleep(29)\n```\n\n```python\n# sends notification on finish\ntime.sleep(31)\n```\n`autonotify` also takes the arguments `--message` / `-m` and `--output` / `-o`.\n\n## Use cell output as message\n\nYou may use the last line of the cell's output as the notification message using `--output` or `-o`. \n\n```python\n%%notify -o\nanswer = 42\n'The answer is {}.'.format(answer)\n```\nNotification message: The answer is 42.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshoprunner%2Fjupyter-notify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshoprunner%2Fjupyter-notify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshoprunner%2Fjupyter-notify/lists"}