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.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9fc01f7ab0bafe889be8db9d12faf7428199fd29c90ff0bdff94f2f1090504c2 |
|
MD5 | 38419fadf3846199abc724187728b5a1 |
|
BLAKE2b-256 | 25b013fd196f0eac594d29a213f3f0ae08dbbf68a3b8782b842906a556f8f66a |
Close
Hashes for jupyterlab_commands-0.2.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | db907fcc116d4454772f5f7585b96a5664384635bf17fb3c381da13ca0c1277e |
|
MD5 | f958d4bb675a2330b40cf2aca3d53743 |
|
BLAKE2b-256 | 13f359ecbc3eb6d29265584712432c9eb2ee9df1db4ec918b4853b26fd4a939f |