Skip to main content

Arbitrary python commands for notebooks in JupyterLab

Project description

jupyterlab_commands

Support for arbitrary python commands in the command palette.

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

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


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.2.tar.gz (184.5 kB view details)

Uploaded Source

Built Distribution

jupyterlab_commands-0.3.2-py2.py3-none-any.whl (25.5 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file jupyterlab_commands-0.3.2.tar.gz.

File metadata

  • Download URL: jupyterlab_commands-0.3.2.tar.gz
  • Upload date:
  • Size: 184.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.7

File hashes

Hashes for jupyterlab_commands-0.3.2.tar.gz
Algorithm Hash digest
SHA256 2ef81ce427c4e5a14d95616400b41ea368e41b5ba2a7fbd88dc4569457cd213a
MD5 2d4ad55b474d1a2398cf25184c552c02
BLAKE2b-256 ad095a3872abb714c64c9237be02c8d4ff29c6d8bc1c787c3be64f89ab132910

See more details on using hashes here.

Provenance

File details

Details for the file jupyterlab_commands-0.3.2-py2.py3-none-any.whl.

File metadata

  • Download URL: jupyterlab_commands-0.3.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 25.5 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.7

File hashes

Hashes for jupyterlab_commands-0.3.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 48a7d13ade06af1defa7f0555ccb10ff46b7a670f51d0202a35cfddf4fc71fd0
MD5 2e863a96b2df13082944f828bb9bf4b5
BLAKE2b-256 40954ac6f24029ac71c0ecf7e9de317c1d2b95e192ae21c360df897a641b43f3

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page