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

Already on GitHub? Sign in to your account

%store magic not auto-restoring #2434

Closed
ivanov opened this Issue Sep 26, 2012 · 7 comments

Comments

Projects
None yet
5 participants
Owner

ivanov commented Sep 26, 2012

I'm not sure when this started happening, I haven't used store in a while, but just ran into this. Basically, storing works, but restores don't automatically happen anymore. We should either:

  1. changes this behavior so that the auto-restores start to happen again (preferred), or
  2. just update the docs to show how to make stored things available (via store -r). See this session
In [1]: pi = 3.1415926

In [2]: pi
Out[2]: 3.1415926

In [3]: store pi
Stored 'pi' (float)

In [4]: store
Stored variables and their in-db values:
pi                  -> 3.1415926

In [5]: 
Do you really want to exit ([y]/n)? y
15:44@~(HbIOTOH)$ ipython
In [1]: pi
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-1-68f7b1e53523> in <module>()
----> 1 pi

NameError: name 'pi' is not defined

In [2]: store
Stored variables and their in-db values:
pi                  -> 3.1415926

In [3]: store -r

In [4]: pi
Out[4]: 3.1415926

whereas the docs suggest one shouldn't need to do store -r:

Example::

  In [1]: l = ['hello',10,'world']
  In [2]: %store l
  In [3]: exit

  (IPython session is closed and started again...)

  ville@badger:~$ ipython
  In [1]: l
  Out[1]: ['hello', 10, 'world']
Owner

takluyver commented Sep 26, 2012

autorestore became configurable, and off by default. You can set c.StoreMagic.autorestore = True if you want it.

Yes, we should update the %store docstring.

Owner

fperez commented Sep 26, 2012

I'm sure I just missed when it happened, but can you point me to the discussion on why the default was changed? It's great that it's now configurable, but changing this default behavior from a long time ago was done for some particularly important reason, I presume?

Owner

takluyver commented Sep 27, 2012

%store was put in quarantine some time ago (probably before 0.11). I resurrected it as an extension (26afef6), at which point you had to add the extension to config to get autorestore. Then in #1073 I made the extension load by default, and added the configuration for autorestore. So it's been a long time since autorestore was happening by default.

Owner

fperez commented Sep 27, 2012

Ah, OK, thanks for refreshing my memory. The question is then: should we make the default True again to match the old behavior, or do we update the docstring?

Owner

takluyver commented Sep 28, 2012

I'd vote for updating the docstring - I think autorestore is potentially
confusing if a user was just playing around with %store, and weeks later
notices that there's a mysterious 'a' variable appearing from nowhere. But
I don't feel strongly about this, and I can see the argument that %store
isn't much use without autorestore.

minrk added a commit to minrk/ipython that referenced this issue Jul 4, 2013

update %store magic docstring
reflects the fact that auto restore is not the default behavior

closes #2434

@Carreau Carreau closed this in #3530 Jul 4, 2013

mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this issue Nov 3, 2014

update %store magic docstring
reflects the fact that auto restore is not the default behavior

closes #2434

You can set c.StoreMagic.autorestore = True if you want it.

Which ~/.ipython file is this supposed to be in?

I can see the argument that %store isn't much use without autorestore.

When you store something for the first time, can it tell you what's going to happen and how to enable autorestore? (Or offer to enable it right there without making you manually edit a config file. You can always tell it to forget things)

Owner

Carreau commented Nov 20, 2014

Probably in one of these 2 depending on the context in which you want to use it:

~/.ipython/profile_default/ipython_config.py
~/.ipython/profile_default/ipython_kernel_config.py

By experience even if we tell things to people the first time, they 1) won't read. 2) won't remember
I don't think autorestore by default make sens especially if you start tens of ipython sessions each days.

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