[IPython-User] notebook magic development questions

Ben Mabey ben@benmabey....
Mon Jan 21 07:12:17 CST 2013


On 1/20/13 11:16 PM, Matthias BUSSONNIER wrote:
> Le 21 janv. 2013 à 06:54, Ben Mabey a écrit :
>
>> On 1/20/13 10:48 PM, Ben Mabey wrote:
>>> Hi all,
>>> I'm new to ipython (and python in general) and am loving the notebook,
>>> thanks for all the work on it!
> Thanks !
>
>>> To facilitate my workflow for data analysis I'm creating some custom
>>> line and cell magics.  For the most part things are straight forward
>>> but I'm unhappy with my current development workflow on the magics. To
>>> develop the magics I have the magic file in the same directory as my
>>> notebook.  I can `%load_ext m
>> Sorry, for the premature send...
>>
>> Anyways, as I was typing.. I can  `%load_ext mymagics` just fine and
>> test my magics but when I change my extension I am having to restart the
>> notebook server before my changes take effect.  I noticed that you can
>> have ipython automatically relaod your code for you[1] and I have tried
>> that but it doesn't seem to be working my the extension I'm creating.
>> How can I have IPython reload my extension so I can test my new changes?
>>
> Hi,
>
> have you try adding an unload capability ?
> http://ipython.org/ipython-doc/dev/config/extensions/index.html#writing-extensions
>
> There might be some case where you can't unload, but at least you should only have to
> restart the current kernel and not the server (from the notebook menu).

For simple extensions do I need to unregister the magic to allow for 
reloading of the code?
This is my simple magic so far dealing with ODBC DB connections:

https://gist.github.com/4585890

In my notebook I am using "%load_ext autoreload" and "%autoreload 2" but 
changes to the extension don't take effect until after I restart the 
kernel.  I have tried reevaluating "%load_ext sqlmagic" but that doesn't 
help either.  Does the extension need to be placed in a certain dir to 
allow for autoreloading?

Thanks,
Ben


More information about the IPython-User mailing list