Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

%store magic not auto-restoring #2434

Closed
ivanov opened this Issue · 7 comments

5 participants

@ivanov
Owner

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']
@takluyver
Owner

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.

@fperez
Owner

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?

@takluyver
Owner

%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.

@fperez
Owner

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?

@takluyver
Owner
@minrk minrk referenced this issue from a commit in minrk/ipython
@minrk minrk update %store magic docstring
reflects the fact that auto restore is not the default behavior

closes #2434
b009e52
@Carreau Carreau closed this in #3530
@mattvonrocketstein mattvonrocketstein referenced this issue from a commit in mattvonrocketstein/ipython
@minrk minrk update %store magic docstring
reflects the fact that auto restore is not the default behavior

closes #2434
6d27873
@endolith

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)

@Carreau
Owner

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
Something went wrong with that request. Please try again.