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.1.tar.gz
(243.5 kB
view hashes)
Built Distribution
Close
Hashes for jupyterlab_commands-0.3.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 08c93994bd83269f7bcfab25ba38ee49308db36b2a50ec25fa53d168d42999d2 |
|
MD5 | 9433ae1c350ce196d5cdb3eccc24fb5d |
|
BLAKE2b-256 | 149c5bf79fc8bedeae223c1e7cc302a8a31bea24be04011d2c324aa059a3ec22 |
Close
Hashes for jupyterlab_commands-0.3.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7bdfdf3acc813cfdbc7a35ef0616f6be32dadc7362e467a36b08c1b3f3b1692f |
|
MD5 | 013e5d086371dcd09422c091e4c9bc41 |
|
BLAKE2b-256 | 30a6794043344b5888e162e3cbeadd541be5269efc4eda4ac86cedbb94437b41 |