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
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.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | a1ac3f607b94ce5167297821cc7ed5058eeca763f4bbce8c1effb9e00504d5ca |
|
MD5 | 1bcc7936600028ae43f8a501948b62ba |
|
BLAKE2b-256 | 37a5435c2d4f8f57494df94c7986e194362e3609a66c3a3ff477e79ff90a77a3 |
Close
Hashes for jupyterlab_commands-0.2.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6d036be7e8a6feda305181dbf4a256330355be116a06ca5792fcf9011748f7ef |
|
MD5 | f86384031bf155922bc45e8eee06ca44 |
|
BLAKE2b-256 | dca06a1b9f320095b2f5b1a62ff3b4fa46e03de078e60615207e540737892003 |