Package: metakernel
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).See Jupyter’s docs onwrapper kernels.Additional magics can be installed within the new kernel package under amagicssubpackage.FeaturesBasic 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 Metakernelmatlab_kernel,https://github.com/Calysto/matlab_kerneloctave_kernel,https://github.com/Calysto/octave_kernelcalysto_scheme,https://github.com/Calysto/calysto_schemecalysto_processing,https://github.com/Calysto/calysto_processingjava9_kernel,https://github.com/Bachmann1234/java9_kernelxonsh_kernel,https://github.com/Calysto/xonsh_kernelcalysto_hy,https://github.com/Calysto/calysto_hygnuplot_kernel,https://github.com/has2k1/gnuplot_kernelspylon_kernel,https://github.com/mariusvniekerk/spylon-kernelwolfram_kernel,https://github.com/mmatera/iwolframsas_kernel,https://github.com/sassoftware/sas_kernelpysysh_kernel,https://github.com/Jaesin/psysh_kernelcalysto_bash,https://github.com/Calysto/calysto_bash… and many others.InstallationYou can install Metakernel throughpip:Installingmetakernelfrom theconda-forgechannel can be achieved by addingconda-forgeto your channels with:Once theconda-forgechannel has been enabled,metakernelcan be installed with:It is possible to list all of the versions ofmetakernelavailable on your platform with:Use MetaKernel Magics in IPythonAlthough MetaKernel is a system for building new kernels, you can use a subset of the magics in the IPython kernel.frommetakernelimportregister_ipython_magicsregister_ipython_magics()Put the following in your (or a system-wide)ipython_config.pyfile:# /etc/ipython/ipython_config.pyc=get_config()startup=['from metakernel import register_ipython_magics','register_ipython_magics()',]c.InteractiveShellApp.exec_lines=startupUse MetaKernel Languages in ParallelTo use a MetaKernel language in parallel, do the following:Make sure that the Python moduleipyparallelis installed. In the shell, type:pipinstallipyparallelTo enable the extension in the notebook, in the shell, type:ipclusternbextensionenableTo start up a cluster, with 10 nodes, on a local IP address, in the shell, type:ipclusterstart--n=10--ip=192.168.1.108Initialize the code to use the 10 nodes, inside the notebook from a host kernelMODULEandCLASSNAME(can be any metakernel kernel):%parallelMODULECLASSNAMEFor example:%parallelcalysto_schemeCalystoSchemeRun code in parallel, inside the notebook, type:Execute a single line, in parallel:%px(+11)Or execute the entire cell, in parallel:%%px(*cluster_rankcluster_rank)Results come back in a Python list (Scheme vector), incluster_rankorder. (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_variableVARIABLEflag, like so:%%px--set_variableresults(*cluster_rankcluster_rank)Then, in the next cell, you can accessresults.Notice that you can use the variablecluster_rankto partition parts of a problem so that each node is working on something different.In the examples above, use-eto evaluate the code in the host kernel as well. Note thatcluster_rankis not defined on the host machine, and that this assumes the host kernel is the same as the parallel machines.ConfigurationMetakernelsubclasses can be configured by the user.  The
configuration file name is determined by theapp_nameproperty of the subclass.
For example, in theOctavekernel, it isoctave_kernel.  The user of the kernel can add anoctave_kernel_config.pyfile to theirjupyterconfig path.  The baseMetaKernelclass offersplot_settingsas 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 plotsc.OctaveKernel.plot_settings=dict(backend='qt')DocumentationExample notebooks can be viewedhere.Documentation is availableonline. Magics have interactivehelp(and online).For version information, see theChangelog.