Arbitrary python commands for notebooks in JupyterLab
Project description
jupyterlab_commands
Support for arbitrary python commands in the command palette.
About
This code lets you inject arbitrary commands into the JLab frontend. There are a variety of reasons why one might want to execute python commands outside of a notebook and a console:
- a predefined NBConvert function that you dont want included in the converted result
- interacting with VCS without including that interaction in the notebook
- etc...
Installation
pip install jupyterlab_commands
jupyter labextension install jupyterlab_commands
jupyter serverextension enable --py jupyterlab_commands
Example
jupyter_notebook_config.py
def convertMe(request, *args, **kwargs):
import subprocess, tornado, os, os.path, json
data = json.loads(tornado.escape.json_decode(request.body))
path = os.path.join(os.getcwd(), data['path'])
subprocess.run(["jupyter", "nbconvert", path, '--template', '/Users/theocean154/.jupyter/test.tpl', '--to', 'html'])
return {'body': 'ok'}
c.JupyterLabCommands.commands = {'sample_command': convertMe}
command palette
terminal log
No Code
Moved to jupyterlab_nbconvert_nocode
Install
pip install jupyterlab_commands
jupyter labextension install jupyterlab_commands
jupyter serverextension enable --py jupyterlab_commands
Adding commands
install the server extension, and add the following to jupyter_notebook_config.py
c.JupyterLabCommands.commands = {'command display name': python_function, ...}
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.
Source Distribution
jupyterlab_commands-0.3.3.tar.gz
(196.2 kB
view hashes)
Built Distribution
Close
Hashes for jupyterlab_commands-0.3.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 732f3d9fa1f78bd09bf0b72a034384d3fb10235a1cfcb5ec7cb4863441f05e1f |
|
MD5 | def1e5cf81af01312dfe968c43522236 |
|
BLAKE2b-256 | ddd0535b98a919893778040aa6658637bda5f7d316caea61d4fe574d2eb1c74e |
Close
Hashes for jupyterlab_commands-0.3.3-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d2b45de1b8ed804c4ca782f726715e881af8ddcdb8038d141e4ad6db3eab6fc4 |
|
MD5 | cf5d54177b6def509732666932c49dd6 |
|
BLAKE2b-256 | b279e34f51230e2a72733133211f7025ebdb65e8f24f21e213cc9f9a1b6abbb3 |