Skip to content
Add arbitrary python commands to the jupyterlab command palette
Python TypeScript Makefile JavaScript
Branch: master
Clone or download
Latest commit 4a21cfe Nov 20, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs add converters Oct 22, 2019
jupyter-config/jupyter_notebook_config.d dist changes Aug 15, 2019
jupyterlab_commands moving converters from lantern to here Oct 22, 2019
src fixes #13 Oct 24, 2019
style adding style Aug 1, 2018
tests fix tests Oct 22, 2019
.bumpversion.cfg dist changes Aug 15, 2019
.gitattributes . Oct 22, 2019
.gitignore add converters Oct 22, 2019
.travis.yml fixes #16 Nov 20, 2019
CONTRIBUTING.md dist changes Aug 15, 2019
LICENSE dist changes Aug 15, 2019
MANIFEST.in add converters Oct 22, 2019
Makefile . Nov 20, 2019
README.md add converters Oct 22, 2019
babel.config.js dist changes Aug 15, 2019
jest.config.js dist changes Aug 15, 2019
package.json . Oct 1, 2019
pyproject.toml dist changes Aug 15, 2019
requirements.txt dist changes Aug 15, 2019
setup.cfg dist changes Aug 15, 2019
setup.py fixes #16 Nov 20, 2019
tsconfig.json dist changes Aug 15, 2019
tslint.json fixes #7 Mar 18, 2019

README.md

jupyterlab_commands

Support for arbitrary python commands in the command palette.

Build Status GitHub issues codecov PyPI PyPI npm

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...

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, ...}
You can’t perform that action at this time.