JupyterKernel GAP Package

by Markus Pfeiffer

Today I released the first beta-version of the package JupyterKernel, a GAP kernel for Jupyter written in GAP.

This has been a while in the making as part of the OpenDreamKit project. In this post I will describe some of the difficulties that I needed to address, and some of the future plans for this.


Ini­tial Im­ple­men­ta­tion and Ob­sta­cles

GAP was written as a programming language with a singular console user interface. While this was entirely reasonable to do when GAP was first developed, we are now having to clean up a lot of what some people call “technical debt”I really don’t like this term.

As a first prototype to see what is possible, I used the example bash kernel for Jupyter: It simply wraps a bash process in a pexpect loop forwarding input from the Jupyter frontend to the process and scraping the output, sending it back to the frontend.

This approach is simple and was implemented in about a couple of hours. Most time was spent battling GAP‘s assumptions about its control over the terminal, and trying to format output nicely. Having GAP, python, and Jupyter to battle with also does not help matters much.

Integrating the help system or visualisations of GAP objects in the Jupyter notebook is entirely impossible in this setting as well, as is most interactive use.