%Store eliminated in configuration and magic commands in 0.11 #684

Closed
excetara2 opened this Issue Aug 7, 2011 · 15 comments

Projects

None yet

3 participants

@excetara2

I had used in console the store command to store macros for multiple sessions. I noticed this has been removed in the console and in qtconsole in 0.11. I haven't seen anything to store macros persistently across sessions so I am guessing this is a regression that should have made it into 0.11 but didn't for one reason or another.

@takluyver
Member

We do intend to restore %store or something equivalent before the next release, I think.

@excetara2

That'd be great. Is there anything similar one can do now to keep macros between sessions. Like a function to declare a macro that could be loaded on ipython startup.

Cheers,
Jeff

@takluyver
Member

If you use the new config files, and find exec_lines, you can store the code in a string and call %macro, something like this:

...exec_lines = ["""mymacrocode = "print 'Hello world!'" """,
                       """%macro mymacro mymacrocode"""]

I haven't tested this, but it should work. I don't think there's a way to interactive store a macro, though.

@excetara2

Thanks for that. I'll check it in the next couple days if that will work
and maybe just write a python function to automate that if it works. I
really don't have that many macros just a couple that I would like to
have stored.

On 07/08/11 21:41, takluyver wrote:

If you use the new config files, and find exec_lines, you can store the code in a string and call %macro, something like this:

...exec_lines = ["""mymacrocode = "print 'Hello world!'" """,
                        """%macro mymacro mymacrocode"""]

I haven't tested this, but it should work. I don't think there's a way to interactive store a macro, though.

@ksolademi

I used store a lot. Guess I'm going back to the old ipython for now.

@excetara2

It is not that bad without it I realized because saves multiline
commands. It searches back through the multi-line commands quickly but
store would still be nice to have.

On 29/09/11 06:16, Keith Solademi wrote:

I used store a lot. Guess I'm going back to the old ipython for now.

@takluyver
Member

Sorry no-one's got round to bringing it back yet. If either of you would like to work on it, you'll need to update the quarantined pspersistence module to the new API. Its current code is here:

https://github.com/ipython/ipython/blob/master/IPython/quarantine/pspersistence.py

We can of course provide more information if you want to ask questions on the mailing list.

@excetara2

Where is the relevant info on the new API? Seems like it shouldn't be
that difficult. If I get time soon, I'll have a go at it.

Cheers

On 29/09/11 10:11, Thomas wrote:

Sorry no-one's got round to bringing it back yet. If either of you would like to work on it, you'll need to update the quarantined pspersistence module to the new API. Its current code is here:

https://github.com/ipython/ipython/blob/master/IPython/quarantine/pspersistence.py

We can of course provide more information if you want to ask questions on the mailing list.

@takluyver
Member

I'm not sure if there is a neat source for what changed, unfortunately. At a brief glance, I think the only thing that changes is how we register magics. Have a look at how it's done for history: https://github.com/ipython/ipython/blob/master/IPython/core/interactiveshell.py#L1875

Also, if you're interested in persistence, I wrote down a few thoughts about what we might do in the future. In particular, using dill (an extension to pickle) might be interesting, because we could store objects like functions which we can't currently.

@excetara2

I'll have a look. Thanks.

On 29/09/11 10:33, Thomas wrote:

I'm not sure if there is a neat source for what changed, unfortunately. At a brief glance, I think the only thing that changes is how we register magics. Have a look at how it's done for history: https://github.com/ipython/ipython/blob/master/IPython/core/interactiveshell.py#L1875

Also, if you're interested in persistence, I wrote down a few thoughts about what we might do in the future. In particular, using dill (an extension to pickle) might be interesting, because we could store objects like functions which we can't currently.

@takluyver
Member

Great, thanks.

To explain a bit more about the initialisation: in the old design, modules
would use ipapi.get() to retrieve the single instance of the
InteractiveShell. The aim is to move InteractiveShell away from being a
singleton (although it still is for now). So modules should have a hook
which gets called as the InteractiveShell is being set up (e.g. extension
modules have a load_ipython_extension hook:
http://ipython.org/ipython-doc/stable/config/extensions.html ).

@takluyver
Member

%store is now back in an extension for 0.12. To load it, do %load_ext storemagic. To have it always loaded, add 'storemagic' to the list c.InteractiveShellApp.extensions in your ipython_config.py file.

@takluyver takluyver closed this Nov 23, 2011
@excetara2

Sorry!! For some reason it didn't work at first try for storing macros that were defined but restarted and now it's a go. THANKS FOR THE HARD WORK!!!!!!

@takluyver
Member

You're welcome. Let me know if you can replicate any problems with it.

I should probably check the documentation, I didn't look at updating any of
it.

@excetara2

I think the documentation appears to be good. I just had forgot that it stores the macro as a variable. Then the variable can be stored.
------Original Message------
From: Thomas
To: excetara2
Subject: Re: [ipython] %Store eliminated in configuration and magic commands in 0.11 (#684)
Sent: Nov 24, 2011 9:20 PM

You're welcome. Let me know if you can replicate any problems with it.

I should probably check the documentation, I didn't look at updating any of
it.


Reply to this email directly or view it on GitHub:
#684 (comment)

Sent via BlackBerry® from Vodafone

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment