Skip to main content

A Jupyter kernel base class in Python which includes core magic functions (including help, command and file path completion, parallel and distributed processing, downloads, and much more).

image

image

image

image

Binder

MetaKernel follows SPEC 0 for minimum supported Python and dependency versions.

See Jupyter's docs on wrapper kernels.

Additional magics can be installed within the new kernel package under a magics subpackage.

Features

  • Basic set of line and cell magics for all kernels.

    • Python magic for accessing python interpreter.
    • Run kernels in parallel.
    • Shell magics.
    • Classroom management magics.
  • Tab completion for magics and file paths.

  • Help for magics using ? or Shift+Tab.

  • Plot magic for setting default plot behavior.

Kernels based on Metakernel

... and many others.

Installation

You can install Metakernel through pip:

pip install metakernel --upgrade

Installing metakernel from the conda-forge channel can be achieved by adding conda-forge to your channels with:

conda config --add channels conda-forge

Once the conda-forge channel has been enabled, metakernel can be installed with:

conda install metakernel

It is possible to list all of the versions of metakernel available on your platform with:

conda search metakernel --channel conda-forge

Use MetaKernel Magics in IPython

Although MetaKernel is a system for building new kernels, you can use a subset of the magics in the IPython kernel.

from metakernel import register_ipython_magics
register_ipython_magics()

Put the following in your (or a system-wide) ipython_config.py file:

# /etc/ipython/ipython_config.py
c = get_config()
startup = [
   'from metakernel import register_ipython_magics',
   'register_ipython_magics()',
]
c.InteractiveShellApp.exec_lines = startup

Use MetaKernel Languages in Parallel

To use a MetaKernel language in parallel, do the following:

  1. Make sure that the Python module ipyparallel is installed. In the shell, type:
pip install ipyparallel
  1. To enable the extension in the notebook, in the shell, type:
ipcluster nbextension enable
  1. To start up a cluster, with 10 nodes, on a local IP address, in the shell, type:
ipcluster start --n=10 --ip=192.168.1.108
  1. Initialize the code to use the 10 nodes, inside the notebook from a host kernel MODULE and CLASSNAME (can be any metakernel kernel):
%parallel MODULE CLASSNAME

For example:

%parallel calysto_scheme CalystoScheme
  1. Run code in parallel, inside the notebook, type:

Execute a single line, in parallel:

%px (+ 1 1)

Or execute the entire cell, in parallel:

%%px
(* cluster_rank cluster_rank)

Results come back in a Python list (Scheme vector), in cluster_rank order. (This will be a JSON representation in the future).

Therefore, the above would produce the result:

#10(0 1 4 9 16 25 36 49 64 81)

You can get the results back in any of the parallel magics (%px, %%px, or %pmap) in the host kernel by accessing the variable _ (single underscore), or by using the --set_variable VARIABLE flag, like so:

%%px --set_variable results
(* cluster_rank cluster_rank)

Then, in the next cell, you can access results.

Notice that you can use the variable cluster_rank to partition parts of a problem so that each node is working on something different.

In the examples above, use -e to evaluate the code in the host kernel as well. Note that cluster_rank is not defined on the host machine, and that this assumes the host kernel is the same as the parallel machines.

Configuration

Metakernel subclasses can be configured by the user. The configuration file name is determined by the app_name property of the subclass. For example, in the Octave kernel, it is octave_kernel. The user of the kernel can add an octave_kernel_config.py file to their jupyter config path. The base MetaKernel class offers plot_settings as a configurable trait. Subclasses can define other traits that they wish to make configurable.

As an example:

cat ~/.jupyter/octave_kernel_config.py
# use Qt as the default backend for plots
c.OctaveKernel.plot_settings = dict(backend='qt')

Documentation

Example notebooks can be viewed here.

Documentation is available online. Magics have interactive help (and online).

For version information, see the Changelog.

Release files for metakernel 1.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for metakernel 1.0.7
File Size Uploaded
metakernel-1.0.7.tar.gz 238.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for metakernel 1.0.7
File Interpreter ABI Platform
metakernel-1.0.7-py3-none-any.whl Python 3 none any Details

Total release size: 444.7 kB

Release files / metakernel-1.0.7.tar.gz

Download URL metakernel-1.0.7.tar.gz
Size 238.5 kB
Tags Source
SHA-256 checksum
How to use checksums
499a0e399e353e0fb4a74e105ea2ad2aed89a15053a299f5fa93c027d721743a
BLAKE2b-256 checksum
How to use checksums
9495c3e6312e8135ac099d755d50b4f579b3c7c359c2fe5d04828f7b8479643e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / metakernel-1.0.7-py3-none-any.whl

Download URL metakernel-1.0.7-py3-none-any.whl
Size 206.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
75318777e5b7e80c59e9732e9b9b1ac11c85b337f7c9375dfb7a3acce03b936a
BLAKE2b-256 checksum
How to use checksums
161753bdb8b19607336d15b1004dc0b8f032c47aa08d8bc31a6f1fab26983207
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

This release

1.0.7 This release

2 release files

1.0.6

2 release files

1.0.0

2 release files

0.32.0

2 release files

0.30.2

2 release files

0.30.1

2 release files

0.30.0

2 release files

0.29.5

2 release files

0.29.4

2 release files

0.29.0

2 release files

0.28.1

2 release files

0.27.0

2 release files

0.26.1

2 release files

0.26.0

2 release files

0.25.0

2 release files

0.24.4

2 release files

0.24.3

2 release files

0.23.0

2 release files

0.21.1

2 release files

0.20.9

2 release files

0.20.8

2 release files

0.20.7

2 release files

0.20.4

1 release file

0.20.3

2 release files

0.20.2

2 release files

0.20.1

2 release files

0.20.0

2 release files

0.19.1

2 release files

0.19.0

2 release files

0.18.4

2 release files

0.18.3

2 release files

0.18.2

2 release files

0.18.1

2 release files

0.18.0

2 release files

0.17.4

2 release files

0.17.3

2 release files

0.16.3

2 release files

0.16.2

2 release files

0.16.1

2 release files

0.16.0

2 release files

0.15.1

3 release files

0.14.0

3 release files

0.13.7

3 release files

0.13.6

3 release files

0.13.5

3 release files

0.13.0

3 release files

0.12.5

3 release files

0.12.4

3 release files

0.12.2

3 release files

0.12.1

3 release files

0.12

3 release files

0.11.8

3 release files

0.11.7

3 release files

0.11.6

3 release files

0.11.5

3 release files

0.11.3

3 release files

0.11.1

3 release files

0.11.0

3 release files

0.10.6

3 release files

0.10.5

3 release files

0.10.4

3 release files

0.10.3

3 release files

0.10.2

3 release files

0.10.1

3 release files

0.10.0

3 release files

0.9.0

3 release files

0.8.0

3 release files

0.7.0

3 release files

0.6.1

3 release files

0.6.0

3 release files

0.5.1

3 release files

0.3

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page