Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/timkpaine/jupyterlab_commands
Add arbitrary python commands to the jupyterlab command palette
https://github.com/timkpaine/jupyterlab_commands
jupyter jupyterlab jupyterlab-extension
Last synced: 6 days ago
JSON representation
Add arbitrary python commands to the jupyterlab command palette
- Host: GitHub
- URL: https://github.com/timkpaine/jupyterlab_commands
- Owner: timkpaine
- License: apache-2.0
- Created: 2018-08-01T15:55:08.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2024-12-13T13:38:12.000Z (2 months ago)
- Last Synced: 2025-02-05T00:17:28.938Z (14 days ago)
- Topics: jupyter, jupyterlab, jupyterlab-extension
- Language: JavaScript
- Homepage: https://jupyterlab-commands.readthedocs.io
- Size: 2.68 MB
- Stars: 60
- Watchers: 4
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome-jupyter-resources - GitHub - 8% open · ⏱️ 21.07.2022): (JupyterLab扩展)
- best-of-jupyter - GitHub - 4% open · ⏱️ 13.12.2024): (JupyterLab Extensions)
README
# jupyterlab_commands
Support for arbitrary python commands in the command palette.
[](https://github.com/timkpaine/jupyterlab_commands/actions?query=workflow%3A%22Build+Status%22)
[](https://codecov.io/gh/timkpaine/jupyterlab_commands)
[](https://pypi.python.org/pypi/jupyterlab_commands)
[](https://pypi.python.org/pypi/jupyterlab_commands)
[](https://www.npmjs.com/package/jupyterlab_commands)
[](https://mybinder.org/v2/gh/timkpaine/jupyterlab_commands/main?urlpath=lab)## 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
```python
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](https://github.com/timkpaine/jupyterlab_nbconvert_nocode)

## Install
```bash
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`
```python3
c.JupyterLabCommands.commands = {'command display name': python_function, ...}
```