[IPython-dev] IPython3/Jupyter Magics for Python-based kernels
doug.blank at gmail.com
Wed Aug 20 07:22:00 EDT 2014
One of the nice things that the IPython team did for the next version was
to create a base class for creating new kernels for code written in Python,
called wrapper kernels .
Unfortunately, such kernels don't have ! shell commands, nor magics. This
is understandable, as those are tightly integrated with IPython's Python.
However, one could get some of the basic functionality of these features on
top of the wrapper kernel, in a generic way. For example, you could run
shell commands, or have some magics that operate independent of the kernel.
We have created a prototype of magics for wrapper kernels . The code is
in magickernel.py, and the magics are in the folder magics. The current
prototype works like this:
In : %magics
%cd PATH - change current directory of session
%connect_info - show connection information
%download URL [FILENAME] - download file from URL
%html CODE - display code as HTML
%install_magic URL - download and install magic from URL
%latex TEXT - display text as LaTex
%magics - show installed magics
%reload_magics - reload the magics from the installed files
%shell COMMAND - run the line as a shell command
%time COMMAND - show time to run line
%%file FILENAME - write contents of cell to file
%%html - display contents of cell as HTML
%%latex - display contents of cell as LaTeX
%%shell - run the contents of the cell as shell commands
%%time - show time to run cell
! COMMAND ... - execute command in shell
Any cell magic can be made persistent for rest of session by using %%%
The idea is to be able to easily add some standard-like magics to 3rd-party
kernels by using MagicKernel. See the sample wrapperkernel EchoKernel with
magics . Also, the idea here is not to replicate too much what comes
with IPython's Python, but to provide a small, simple core set of magics
that can't be easily done in the kernel language. You can install
MagicKernel from source, or using:
$ pip install calico --upgrade
This is a prototype (with some bugs), and we very much hope for others to
provide feedback or code, and more work needs to be done. What magics would
you need in your 3rd-party kernel, that can be accomplished this way? Will
this design be sufficient?
We hope that this is useful!
 - http://ipython.org/ipython-doc/dev/development/wrapperkernels.html
 - https://bitbucket.org/ipre/calico/src/master/src/calico/
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the IPython-dev