[prev] [up]

Jupyter Kernel

Overview

Jupyter is a Python framework to interact with (multiple) programs in different languages in so called "notebooks" in a web browser.
It enables "executable documentation" and "executable examples" by realizing pages with both text, links, graphics and embedded active computation cells. These cells are connected to so called "language kernels" which provide computations.

Originally meant as a framework for Python, many other language kernels have been added, to provide an interactive execution environment for script-like execution of code fragments (i.e. Python, R, Ruby, Haskell, Node, Go, Smalltalk and others).

The "stx:goodies/communication/jupyter" package implements such a kernel for Smalltalk/X.

Documentation

Please refer to the official Jupyter documentation for details,
and of course: use the source - Luke.

Setup & configuration

Prerequisites

Kernel Config Files

Kernels are configured in json-formatted kernel-config files, which are located under the base Jupyter installation folder.
The details vary between operating systems - if uncertain, search for folders named "kernels" on your machine (under the Jupyter install folder).
For example, on OS X, kernel-configs for all users are found under:
    /Library/Frameworks/Python.framework/Versions/3.7/share/jupyter/kernels
and per-user specs under:
    $(HOME)/Library/Jupyter/kernels
A similar structure is used on Windows or Linux.

To see where your Jupyter stores the specs, type:

    jupyter kernelspec list

Adding a Smalltalk/X Kernel Config File

The ST/X package includes a convenient method, which creates and adds a kernel.json file for stx; run this (on the command line) with:
    stx --run stx:goodies/communication/jupyterTalk --install
If that fails to find a target folder, perform the following steps:

Starting Jupyter

To test, open a command (xterm) window, and input to a shell prompt:
    jupyter notebook
or
    jupyter lab
After some startup time, a browser window should appear, showing the initial Jupyter notebook.

In Jupyter, press the "New" button at the top right, and choose "Smalltalk/X". In JypyterLab, select "New" from the top menu. If there is no entry for "Smalltalk/X", you might have a problem with your kernel config file (wrong pathname or Jupyter uses a different config folder).

An empty cell into which you can enter a Smalltalk expression should appear. Try "3+4" and press "Run" (the right-arrow button in the toolbar). If all goes well, a result cell containing "7" should appear (obviously).

Try "Smalltalk openDisplay. NewLauncher open.". The standard Smalltalk/X launcher will appear.

Loading

Execute in a workspace:
    Smalltalk loadPackage:'stx:goodies/communication/jupyter'
or:
    Smalltalk requirePackage:'stx:goodies/communication/jupyter'

Notice:
Jupyter will start a fresh Smalltalk/X binary, and the kernel configuration will tell it to load the package upon startup. Thus, if you modify any code, you'll have to save the affected classes back into the package folder, recompile the package library (in "stx/goodies/communication/jupyter"), and restart the kernel.

Prerequisites

Jupyter uses zeroMQ as communication protocol. The required zeroMQ interface library is also found in the "stx/goodies/communication" folder.

No Warranty

This goody is provided AS-IS without any warranty whatsoever.

Origin/Authors

Claus Gittinger (ported from Squak/Pharo)


<info@exept.de>

Doc $Revision: 1.9 $