These are chat archives for ipython/ipython

27th
Aug 2015
Tomas Ostasevicius
@to266
Aug 27 2015 11:53

Hi,
Are there any plans to change how custom magics are defined? As far as I can tell, it has to be done either by an extension, or in the ipython profile (which got somewhat more complicated with Ipython 4.0).

What I would highly prefer instead would be to install them with pip, just as it is possible to do for extensions.
Thoughts?

Matthias Bussonnier
@Carreau
Aug 27 2015 12:13
@to266 yes, custom magics should be just pip packages. You don't need to add them to your profiles and config. IPython profile are not gone. Jupyter just not have notion of profile, but IPython still have.
Matthias Bussonnier
@Carreau
Aug 27 2015 13:10
@rgbkrk ping
Kyle Kelley
@rgbkrk
Aug 27 2015 13:21
@Carreau pong
Though we're on appear.in so I don't need to respond now
Tomas Ostasevicius
@to266
Aug 27 2015 13:22
@Carreau is there currently a way to create custom magic as pip package and I'm just unaware? That would be awesome..
Matthias Bussonnier
@Carreau
Aug 27 2015 13:22
magics are just python packages that define a magic function
Tomas Ostasevicius
@to266
Aug 27 2015 13:34
Thanks for the example. In this case, though, you have to import the specific magic package before it's available, right?
In my case the magic would essentially be very similar to the %pylab (i.e. imports other stuff), so importing it beforehand defeats the purpose (you don't have to remember what to import, and the magic is available with autocomplete)
Matthias Bussonnier
@Carreau
Aug 27 2015 13:41
if it's just to import things then use a metapackage and use from dummy import *. "Explicit is better than implicit.", and pylab is annoying because it does implicit things.
Tomas Ostasevicius
@to266
Aug 27 2015 13:47

Well in my case the magic has an optional argument, that changes how it behaves, here is the actual code:
https://github.com/hyperspy/hyperspy/blob/master/hyperspy/misc/hyperspy_magics.py

It's really as explicit as I was able to make it (i.e. it either just prints the code that was executed, or actually replaces the cell content with the code, and later the magic is not run at all)
So I guess the dummy package is not environment-aware, and we need it

Tomas Ostasevicius
@to266
Aug 27 2015 17:15

Ok, an actual question:

Is the part about auto-loading extensions in here still relevant ? https://ipython.org/ipython-doc/dev/config/extensions/index.html#using-extensions

I guess it does not make sense to add python-specific extensions to be auto-loaded in jupyter config, however I can't see how the same behaviour can be acheved for the notebook.
Thanks :)

Damjan Dimitrioski
@gnud
Aug 27 2015 17:53
Hi, I'm trying to execute raw commands from javascript in the IPython notebook using the inspector's console, how do I get the shell output ?
I'm using this code: IPython.notebook.kernel.execute('print("{result:""}")', cb, {}); where cb is a callback function, the execution is ok, however I only get the id of the transaction, how do I subscribe for reply messages ?
Damjan Dimitrioski
@gnud
Aug 27 2015 18:56
I found out, all I needed was instead of a callback, an object having callback named { iopub: callback} :D, now it works