A small, simple kernel example for IPython
Clone or download
Latest commit f0d836e Nov 3, 2017
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
LICENSE.md Update and rename LICENSE to LICENSE.md May 1, 2016
README.md fix readme.md Nov 3, 2017
SimpleKernel.cs Working C# version Feb 5, 2015
install_script.sh Update version of simple_kernel requests Aug 9, 2015
simple_kernel.py support for Python 3 Jan 19, 2016

README.md

simple_kernel

A small, simple kernel example for Jupyter, specification version: 5.0

Run

Download and run:

ipython console --KernelManager.kernel_cmd="['python', 'simple_kernel.py', '{connection_file}']"

ipython notebook --KernelManager.kernel_cmd="['python', 'simple_kernel.py', '{connection_file}']"

ipython qtconsole --KernelManager.kernel_cmd="['python', 'simple_kernel.py', '{connection_file}']"

Alternative way

Install Jupyter

$ git clone https://github.com/jupyter/notebook.git
$ cd notebook
$ mkvirtualenv jupyter-env
$ workon jupyter-env
(jupyter-env) $ pip install --pre -e .
(jupyter-env) $ pip install jupyter-console

Download project to the different directory, install (prepare kernel.json file with install_script.sh script) and run:

(jupyter-env) $ git clone https://github.com/dsblank/simple_kernel.git
(jupyter-env) $ ./install_script.sh
(jupyter-env) $ jupyter console --kernel simple_kernel

Testing kernel

You can test your project using jupyter_kernel_test project.

Clone this project:

(jupyter-env) $ git clone https://github.com/jupyter/jupyter_kernel_test
(jupyter_env) $ cd jupyter_kernel_test

Modify test_ipython.py file to look like this:

import unittest
import jupyter_kernel_test as jkt

class IRkernelTests(jkt.KernelTests):
    kernel_name = "simple_kernel"
    language_name = "simple_kernel"

    code_hello_world = "print('hello, world')"

if __name__ == '__main__':
    unittest.main()

and run this project with following command:

(jupyter-env) $ python test_ipython.py

Output should be similar to this:

### some debug information
----------------------------------------------------------------------
Ran 5 tests in 1.034s

OK (skipped=3)

Current status

Features:

  • shell, heartbeat, and iopub channels working
  • signatures are correct
  • need to test control and stdin channels
  • need to handle "magics"

Bugs:

  1. when running a console, doesn't stop python when exiting

References

These references may be helpful in understanding the big picture of IPython and zmq.

  1. http://ipython.org/ipython-doc/dev/development/messaging.html - Messaging documentation
  2. http://andrew.gibiansky.com/blog/ipython/ipython-kernels/ - Useful document in making a kernel
  3. http://zeromq.github.io/pyzmq/api/index.html - 0MQ Documentation for low-level socket functionality

Other Kernel Examples

Here is a list of all of the standalone kernels (backends) that I know about. I don't think I got a single one to run, however.