cptpiepmatz / nu-jupyter-kernel

📓 A wip jupyter raw kernel for nu
MIT License
32 stars 4 forks source link
jupyter-kernel nushell

nu-jupyter-kernel

A jupyter raw kernel for nu.


crates.io Version Nu Version Jupyter Protocol Version License

About

nu-jupyter-kernel is a Jupyter kernel specifically for executing Nu pipelines. Unlike most Jupyter kernels that rely on Python, this raw kernel directly implements the Jupyter messaging protocol, allowing direct communication without Python intermediaries. It's designed to work seamlessly with Nu, the language utilized by Nushell — a modern shell that emphasizes structured data.

screenshot

Features

The nu-jupyter-kernel has several features making it a useful kernel for Jupyter notebooks:

Examples

In the "examples" directory are some notebooks that show how the kernel works. Opening the examples on Github also shows a preview of them.

Design Goals

The design of the nu-jupyter-kernel focuses on the following goals:

Installation

To build the kernel you need to have the rust toolchain installed, check the installation guide on rust's official website.

Using cargo install nu-jupyter-kernel you can install the latest release of the kernel. If you want to install the latest version on the git repo, you can install the kernel via cargo install nu-jupyter-kernel --git https://github.com/cptpiepmatz/nu-jupyter-kernel.git

Usage

Registering the Kernel

After installation, you must register the kernel to make it available within Jupyter environments. This can be done through the command:

nu-jupyter-kernel register

You can specify the registration scope using --user for the current user (default) or --system for system-wide availability.

Using the Kernel

Both options may require a restart after registering the kernel.

Note on Updates

Kernel binary updates do not require re-registration unless the binary's location changes. For developers, keep in mind that running cargo run register and cargo run --release register will result in different binary locations.

Version Scheme

This crate follows the semantic versioning scheme as required by the Rust documentation. The version number is represented as x.y.z+a.b.c, where x.y.z is the version of the crate and a.b.c is the version of the nu-engine that this crate is built with. The + symbol is used to separate the two version numbers.

Contributing

Contributions are welcome! If you're interested in contributing to the nu-jupyter-kernel, you can start by opening an issue or a pull request. If you'd like to discuss potential changes or get more involved, join the Nushell community on Discord. Invite links are available when you start Nushell or on their GitHub repository.

Testing

This project uses uv for integration testing. Since tools for executing Jupyter notebooks are not currently available in Rust, the tests are handled via Python.

To run the tests, follow these steps:

  1. Register the kernel:
    cargo run register
  2. Sync Python dependencies:
    uv sync
  3. Run the tests:
    uv run pytest

Make sure uv is installed before running the commands.