[IPython-dev] Implementing inline images in a kernel

Brian Granger ellisonbg at gmail.com
Wed Jan 29 13:24:17 EST 2014


> Calico interpreting whatever language shows the output intermittently
> over the course of the 10 seconds, just like IPython running the
> Python kernel. Calico doesn't "talk" to a Python backend... Calico
> *is* Python, in a sense. And it is also Basic, Logo, etc. There isn't
> one primary language talking to the others---there is just the thin
> socket kernel talking to a specific language's eval function. But the
> eval occurs in the "same space". Lower level calls to functions like
> print() in the interpreted language's eval() inject messages to the
> iopub stream. Even our Java works this way.

Great, this is also how the %julia magic works. By having shared
objects that can all access the same messaging layer, you co go a lot
further. Asynchronous output (including rich) shouldn't be too bad.
The important thing is that there be a common messaging API that all
of the sub-kernels can access to send messages asynchronously. Tab
completion might be a bit of a pain, but can probably be done with
this approach as well.

I think the widgets are going to be a bit more difficult. I think you
will be able to get them working, but with some serious reinvention.
What do I mean by that. We already have a relatively full set of
Python widgets shipping with IPython 2.0. Other people will start to
write 3rd party widgets for Python as well. But these use the IPython
kernel implementation of the widget/comm infrastructure:

https://github.com/ipython/ipython/wiki/IPEP-21%3A-Widget-Messages

you will need to implement this layer in your main/sub kernels. The
problem is that widgets in your kernels will need to use your layer
for this. This means you will also have to re-implement the actual
Python widgets to use your layer instead of the normal IPython one.
You might be able to monkey patch things to get this stuff working,
but it could be a serious amount of work. Over time, as the number and
complexity of widgets grows, this will require a substantial effort to
do.

> This is why I find some of the assumptions stated
> confusing---insisting that "one language/one kernel" is the future
> apparently misses some possibilities in design :) It may be that we
> made unique design decisions. In any event, it appears that Calico
> running scripts is very different in a fundamental way that IPython's
> Python running the integrated Julia.

There are two issues:

* Can the meta kernel thing be done: depending on how it is designed,
to some degree yes.
* Does it make sense to create meta kernels: my own feeling is that it
does not in general. Obviously, IPython, through cell magics does
offer some of this in limited form. But we definitely don't have plans
on trying to add things like tab completion+widgets to these cell
magics. My main problem with meta kernels though is not technical, but
conceptual. Most users, even very advanced ones, have plenty enough
cognitive load when working with 1 programming language. To ask them
to manage multiple languages in the same namespace is a huge ask that
is probably DOA for all but the most advanced users.

Cheers,

Brian

> I wonder what the best technical way to describe this difference is? I
> guess that you had assumed some type of blocking behavior. Perhaps I
> need a better way of describing how Calico operates. My question to
> you is why does %julia block?
>
> -Doug
>
>> On Wed, Jan 29, 2014 at 12:14 AM, Doug Blank <doug.blank at gmail.com> wrote:
>>> On Wed, Jan 29, 2014 at 3:10 AM, Brian Granger <ellisonbg at gmail.com> wrote:
>>>>
>>>> > That's interesting... IJulia using the Python VM... Then, this is very
>>>> > similar to Calico. Because all of the languages share memory, I was able
>>>> > to
>>>> > put a global object in there. I have now written display(), HTML(),
>>>> > Image(),
>>>> > and Audio(), and all is working very well. HTML, Image, and Audio all
>>>> > have a
>>>> > specially named method (similar to Python's __rep__) that when called,
>>>> > returns the dictionary of mime-types and strings, and display() sends
>>>> > the
>>>> > proper message. Demo to follow...
>>>>
>>>> That is absolutely similar to the Calico idea. But keep in mind,
>>>> running Julia through the %julia magic will *never* allow things like
>>>> the widgets or tab completion to work. Only the true native Julia
>>>> kernel will allow that.
>>>>
>>>
>>> Why can't the Julia-using-the-PythonVM magic use the widgets or tab
>>> completion? What is the limitation?
>>>
>>> -Doug
>>>
>>>>
>>>>
>>>> > -Doug
>>>> >
>>>> >>
>>>> >> Cheers,
>>>> >>
>>>> >> f
>>>> >>
>>>> >>
>>>> >> --
>>>> >> Fernando Perez (@fperez_org; http://fperez.org)
>>>> >> fperez.net-at-gmail: mailing lists only (I ignore this when swamped!)
>>>> >> fernando.perez-at-berkeley: contact me here for any direct mail
>>>> >>
>>>> >> _______________________________________________
>>>> >> IPython-dev mailing list
>>>> >> IPython-dev at scipy.org
>>>> >> http://mail.scipy.org/mailman/listinfo/ipython-dev
>>>> >>
>>>> >
>>>> >
>>>> > _______________________________________________
>>>> > IPython-dev mailing list
>>>> > IPython-dev at scipy.org
>>>> > http://mail.scipy.org/mailman/listinfo/ipython-dev
>>>> >
>>>>
>>>>
>>>>
>>>> --
>>>> Brian E. Granger
>>>> Cal Poly State University, San Luis Obispo
>>>> bgranger at calpoly.edu and ellisonbg at gmail.com
>>>> _______________________________________________
>>>> IPython-dev mailing list
>>>> IPython-dev at scipy.org
>>>> http://mail.scipy.org/mailman/listinfo/ipython-dev
>>>
>>>
>>>
>>> _______________________________________________
>>> IPython-dev mailing list
>>> IPython-dev at scipy.org
>>> http://mail.scipy.org/mailman/listinfo/ipython-dev
>>>
>>
>>
>>
>> --
>> Brian E. Granger
>> Cal Poly State University, San Luis Obispo
>> bgranger at calpoly.edu and ellisonbg at gmail.com
>> _______________________________________________
>> IPython-dev mailing list
>> IPython-dev at scipy.org
>> http://mail.scipy.org/mailman/listinfo/ipython-dev
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev



-- 
Brian E. Granger
Cal Poly State University, San Luis Obispo
bgranger at calpoly.edu and ellisonbg at gmail.com



More information about the IPython-dev mailing list