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
Built Distribution
Close
Hashes for jupyterlab_commands-0.2.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 54df8f23500de5bcd6fc0dab50451450fe35440ddb82aa7c3a5f9c4146bccff0 |
|
MD5 | e4d184459013112d0659514fe9287c64 |
|
BLAKE2b-256 | 2d565af34ca4139f8e22f04f4708835203f62e1b2089c2c156acf2c8d70cfb63 |
Close
Hashes for jupyterlab_commands-0.2.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f5deab5291596e51f12f7cf4d735ddd87c1c719fddcced22910860aff36dcecb |
|
MD5 | aacd0ea694d4f0e48fa64e6f43cf62aa |
|
BLAKE2b-256 | d5da90a6bab0a67831c1b5b562e4971151c7dab4bfe6b7fae7402c9d72f09ef7 |