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.0.tar.gz
(214.9 kB
view details)
Built Distribution
File details
Details for the file jupyterlab_commands-0.3.0.tar.gz
.
File metadata
- Download URL: jupyterlab_commands-0.3.0.tar.gz
- Upload date:
- Size: 214.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.1 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9ce9c2542fcb5715ae710c12ea87105e1e1bb7606fbe584d3aed5e3af2d41f0a |
|
MD5 | 6f8652666dc739a1091240096f2bfe40 |
|
BLAKE2b-256 | 382918bc14500d28ec52cbb28ba5bd1284f37ce80c672d69d3bf75d3fb6ad03a |
Provenance
File details
Details for the file jupyterlab_commands-0.3.0-py2.py3-none-any.whl
.
File metadata
- Download URL: jupyterlab_commands-0.3.0-py2.py3-none-any.whl
- Upload date:
- Size: 12.4 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.1 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 68edf7ff33736f52186feb0de244f49d5fdeaedac38cbd147d9d01659b3a1bb2 |
|
MD5 | 980940a9be3415e51a33ade44095fd75 |
|
BLAKE2b-256 | eed3bb56774da44c275708cfb21d0bce1c99c8fffaa48a508050951c07ae81b3 |