jupyter-notify:Jupyter Notebook魔术,用于浏览器通知单元完成

  • E2_256044
    了解作者
  • 13.4KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-05-05 21:18
    上传日期
用于完成单元格的浏览器通知的Jupyter Magic 该软件包提供了Jupyter笔记本电脑电池魔术%%notify ,该组件可通过浏览器推送通知在用户可能长时间运行的电池单元完成时通知用户。 用例包括长期运行的机器学习模型,网格搜索或Spark计算。 这种魔力使您可以导航到其他工作(甚至完全是另一个Mac桌面),并且在单元完成时仍会收到通知。 单击通知的正文将直接带您进入笔记本的浏览器窗口和选项卡,即使您位于其他桌面上(单击通知中的“关闭”按钮也可以使您身在其中)。 支持的浏览器 目前,该扩展程序已在Chrome(版本:58.0.3029)和Firefox(版本:53.0.3)中进行了测试。 注意:Firefox也使得当通知火灾(声音可以在OS X中所描述的关闭听得见的钟声)。 远程服务器注意事项:此扩展名也将在远程服务器上工作。 但是,您需要在https上运行jupyter笔记
jupyter-notify-main.zip
  • jupyter-notify-main
  • jupyternotify
  • js
  • notify.js
    1.7KB
  • init.js
    405B
  • jupyternotify.py
    5.9KB
  • __init__.py
    135B
  • tests
  • test_notebook.ipynb
    4.1KB
  • MANIFEST.in
    43B
  • README.rst
    5.1KB
  • LICENSE.txt
    1.4KB
  • AUTHORS.txt
    213B
  • requirements.txt
    16B
  • setup.py
    1019B
  • README.md
    5.3KB
  • Makefile
    453B
  • .gitignore
    1KB
  • CHANGELOG.md
    1.3KB
内容介绍
[![pypiv](https://img.shields.io/pypi/v/jupyternotify.svg)](https://pypi.python.org/pypi/jupyternotify) [![pyv](https://img.shields.io/pypi/pyversions/jupyternotify.svg)](https://pypi.python.org/pypi/jupyternotify) [![License](https://img.shields.io/pypi/l/jupyternotify.svg)](https://github.com/ShopRunner/jupyter-notify/blob/main/LICENSE.txt) [![Thanks](https://img.shields.io/badge/Say%20Thanks-!-1EAEDB.svg)](https://saythanks.io/to/mdagost) <img src="https://s3.amazonaws.com/shoprunner-github-logo/shoprunner-logo.svg" alt="ShopRunner logo" width="300"/> # A Jupyter Magic For Browser Notifications of Cell Completion <img src="https://s3.amazonaws.com/shoprunner-github-logo/jupyter_chrome.png" alt="Jupyter notebook notification in Chrome" width="750"/> <img src="https://s3.amazonaws.com/shoprunner-github-logo/jupyter_firefox.png" alt="Jupyter notebook notification in Firefox" width="750"/> 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. 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). ### 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](https://stackoverflow.com/questions/27491672/disable-default-alert-sound-for-firefox-web-notifications)). **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). ## 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: ``` bash 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: ``` python %load_ext jupyternotify ``` ### Automatically load in all notebooks Add the following lines to your ipython startup file: ``` c.InteractiveShellApp.extensions = [ 'jupyternotify' ] ``` 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](http://ipython.org/ipython-doc/dev/config/intro.html) for more info). To test the extension, try ``` %%notify import time time.sleep(5) ``` ## Options NOTE: Currently options cannot be used with `%load_ext` or the ipython startup file instructions above. To load the magic with options, you should load it manually by doing the following: ```python import jupyternotify ip = get_ipython() ip.register_magics(jupyternotify.JupyterNotifyMagics( ip, option_name="option_value" )) ``` or add this to your ipython startup file: ```python c.InteractiveShellApp.exec_lines = [ '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: ```python %%notify -m "sleep for 5 secs" import time time.sleep(5) ``` <img src="https://s3.amazonaws.com/shoprunner-github-logo/jupyter_custom_message.png" alt="Jupyter notebook notification with custom message" width="750"/> ## Fire notification mid-cell You may also fire a notification in the middle of a cell using line magic. ```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>`. ```python import numpy as np import time # autonotify on completion for cells that run longer than 30 seconds %autonotify -a 30 ``` Then later... ```python # no notification time.sleep(29) ``` ```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`. ```python %%notify -o answer = 42 'The answer is {}.'.format(answer) ``` Notification message: The answer is 42.
评论
    相关推荐
    • firefox xpi
      NULL 博文链接:https://citi21558541.iteye.com/blog/1097152
    • firefox plugin
      NULL 博文链接:https://xiejiangbo.iteye.com/blog/778543
    • firefox xpi
      NULL 博文链接:https://citi21558541.iteye.com/blog/1097152
    • Firefox扩展
      NULL 博文链接:https://lstoryc.iteye.com/blog/2066120
    • firefox插件
      NULL 博文链接:https://zhonghuart.iteye.com/blog/1674763
    • firefox 扩展
      NULL 博文链接:https://citi21558541.iteye.com/blog/1095380
    • firefox
      NULL 博文链接:https://moving200x.iteye.com/blog/788047
    • FireFox
      NULL 博文链接:https://slgworld.iteye.com/blog/996052
    • fireFox 29
      NULL 博文链接:https://hoochiang.iteye.com/blog/2065530
    • firefox xpi
      NULL 博文链接:https://citi21558541.iteye.com/blog/1097681