Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

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

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

excetara2 opened this issue Aug 7, 2011 · 15 comments
Milestone

Comments

@excetara2
Copy link

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
Copy link
Member

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

@excetara2
Copy link
Author

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
Copy link
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
Copy link
Author

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
Copy link

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

@excetara2
Copy link
Author

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
Copy link
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
Copy link
Author

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
Copy link
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
Copy link
Author

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
Copy link
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
Copy link
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.

@excetara2
Copy link
Author

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
Copy link
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
Copy link
Author

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants