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_lab_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, '--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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jupyterlab_commands-0.4.0.tar.gz.
File metadata
- Download URL: jupyterlab_commands-0.4.0.tar.gz
- Upload date:
- Size: 160.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
210c851ee4c7439ac593018542c599a9085e459bc1bc1fb3ea92d2a9bf3e11ff
|
|
| MD5 |
8227498726694de58587d23b23413ae4
|
|
| BLAKE2b-256 |
02ba992cd163d9474bc40986fee3ebe3adddb32bdc3de58dd35677eb473dfcb1
|
File details
Details for the file jupyterlab_commands-0.4.0-py3-none-any.whl.
File metadata
- Download URL: jupyterlab_commands-0.4.0-py3-none-any.whl
- Upload date:
- Size: 44.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3382bf4062ea0c6f001976403ee3c45a477cc0fb7abd146fd86ef7e079b50ef3
|
|
| MD5 |
f6eda21b1201226fc7e30ee9d5a250b0
|
|
| BLAKE2b-256 |
dac8e01f31d1d27b2e114bb6fea834f1e18952d04136871f5dc07720153cf65a
|