Rand Stats

Jupyter::Kernel

cpan:BDUGGAN

Jupyter::Kernel for Raku

Binder

autocomplete

This is a pure Raku implementation of a Raku kernel for Jupyter clients¹.

Jupyter notebooks provide a web-based (or console-based) Read Eval Print Loop (REPL) for running code and serializing input and output.

REALLY QUICK START

Binder provides a way to instantly launch a Docker image and open a notebook². Click launch | binder above to start this kernel with a sample notebook. (See below for similar alternatives.)

QUICK START

Installation

You'll need to install zmq. Note that currently, version 4.1 is recommended by Net::ZMQ (though 4.2 is installed by, e.g. homebrew). If you run into stability issues, you may need to downgrade.

brew install zmq           # on OS/X
apt-get install libzmq-dev # on Ubuntu

You'll also want jupyter, for the front end:

pip install jupyter

Finally, install Jupyter::Kernel:

zef install Jupyter::Kernel

At the end of the above installation, you'll see the location of the bin/ directory which has jupyter-kernel.raku. Make sure that is in your PATH.

Configuration

Server Configuration

To generate a configuration directory, and to install a kernel config file and icons into the default location:

jupyter-kernel.raku --generate-config

Logging

By default a log file jupyter.log will be written in the current directory. An option --logfile=XXX argument can be added to the argv argument of the server configuration file (located at $(jupyter --data)/kernels/raku/kernel.json) to change this.

Client configuration

The jupyter documentation describes the client configuration. To start, you can generate files for the notebook or console clients like this:

jupyter notebook --generate-config
jupyter console --generate-config

Some suggested configuration changes for the console client:

Running

Start the web UI with:

jupyter-notebook
Then select New -> Raku.

You can also use it in the console like this:

jupyter-console --kernel=raku

Or make a handy shell alias:

alias iraku='jupyter-console --kernel=raku'

FEATURES

Usage notes

In [1]: 42
Out[1]: 42

In [2]: 42 +
Out[2]: Missing required term after infix

In [3]: 42 + \
      : 10 + \
      : 3 + \
      : 12
Out[3]: 67

Note that this is not the same as the raku 'unspace' -- a backslash followed by a newline will be replaced with a newline before the code is executed. To create an unspace at the end of the line, you can use two backslashes.

DOCKER

This blog post provides a tutorial for running this kernel with Docker. This one describes using Binder.

EXAMPLES

The eg/ directory of this repository has some example notebooks:

SEE ALSO

KNOWN ISSUES

THANKS

Matt Oates

Suman Khanal

Timo Paulssen

Tinmarino

Anton Antonov

FOOTNOTES

¹ Jupyter clients are user interfaces to interact with an interpreter kernel like Jupyter::Kernel. Jupyter [Lab | Notebook | Console | QtConsole ] are the jupyter maintained clients. More info in the jupyter documentations site.

² mybinder.org provides a way to instantly launch a Docker image and open a notebook.