-
-
Notifications
You must be signed in to change notification settings - Fork 182
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
Can't dump_session with inline plots #4
Comments
@niallrobinson: This is a known issue for pickling of matplotlib objects. Several years ago, at a scipy sprint, I tried see how far dill could go with pickling matplotlib objects, and ran into issues on the objects you list above. There's some "tricky" things that are being done in matplotlib with weakrefs and the like that make the objects unpicklable, even with dill, for the moment. I'd need to talk to the matplotlib team. In many cases, it's just a matter of moving a line of code (say an import) to another level in the object hierarchy. ipython is a good use case for why matplotlib objects should be picklable... also it could allow matplotlib to be sped up by doing parallel computing on each of the different graphics layers. The good news is that once it would work with matplotlib objects, then it'd work in ipython. This will take some time, however, and someone on the matplotlib team's interest in getting it done. It looks like the right guys to ping about this initially are @ivanov and @fperez. There are some things that I can do in dill to help it out, but it's really a case of dev in matplotlib... and that means it be a big help if someone there is interested in it happening. |
What version of matplotlib are you on? For 1.3.0, @pelson added a great deal of support for pickling... But I haven't tried what you describe to confirm. |
@mdboom: Last I tried was in version 1.1.0 and 1.2.0. So, I'm a few months off the current one. I will update to 1.3.0 and give it a try. I'm not sure about what version of matplotlib the reporter @niallrobinson is on. If you want to test pickling anything with dill, all you have to do is type: Install dill from the github site, if you want to give it a try. It's a very small pure python package with no dependencies. |
Yep. I think we labelled it "experimental" in the what's new, but certainly anything that isn't too fruity can be pickled in v1.3.0. Anything that remains is an oversight and can be considered a bug, so please fire away bug reports to the mpl tracker and I'll get on to them. |
I'm currently on 1.2.0rc2, so I'll see if 1.3 sorts any of the problems. |
Unfortunately I get the same behaviour with matplotlib 1.3 |
@niallrobinson: This should probably move over to matplotlib's issue tracker -- please bug report your issue there. However, I'd appreciate keeping me in the loop... I may be able to help with the serialization. I'll update and try myself (and I may want to link the related mpl issue from here). |
We don't store the RenderAgg object when pickling figures (in fact, one of the cool features is that you can pickle a figure from one backend, and re-attach it to another, that is probably news to even @mdboom 😉) so I think there is probably some deep inspection of all objects which exist in the current session which is being a little too deep, it's uncertain to me where that inspection lies: it could be IPython or it could be dill... |
@pelson: So the issue that started this thread is that one of the things that dill provides is a serialization of an entire active interpreter session, where you can start a new interpreter and then resume the pickled session where you left off. That means, if you have an Agg object in the interpreter session (esp. in
That will show what needs work for an interpreter session with a plot to be serialized. I have a debug flag that can be turned on with |
I'll be investigating as soon as I can. |
Does anyone know if anyone has had a chance to look at this? Not meaning to pester, just thought I'd ask in case I'd missed it. |
@niallrobinson: I have not looked at it yet. I've been tied up for a few weeks, but should get to it soon. |
Hi, @mmckerns, how is this issuing coming along? I recently tried dill.dump_session() in a ipython notebook and still got the same error. I am using ipython 2.1 and matplotlib 1.4. As you mentioned, the ability to serialize entire active interpreter session and then resume the pickled session later is a big plus for ipython notebook. I'd like to know if there is workarounds or alternatives I can try! |
@jianlingzh: It would be a very cool feature for IPython... however, this issue is still very much open, and to be honest, I haven't touched it in a long while. It'd take digging into the guts of both matplotlib (and possibly how IPython handles matplotlib)… and I've not done it. |
Thanks, @mmckerns! Is there any way to work around this currently? Like ask dill to ignore certain matplotlib objects when dumping the session? |
I don't know of any current workaround, but having a list or dict of |
I wasn't able to reproduce this with mpl v1.3.1, IPython 2.2, and dill 0.2.1 - @jianlingzh, could you produce a notebook which I can run to reproduce the problem exactly? (a gist would be great) |
@pelson, this isn't hard for me to reproduce. Just a couple of lines:
will show the error that started this thread. I tried matplotlib 1.4.0, dill 0.2.1 on both IPython 2.1 and 2.2, both created the error. Did you have the pylab = 'inline' config in your ipython notebook config file?
|
I have added a bunch of pickling error detection and introspection methods since this thread started -- in |
No! This is the reason... I never use pylab, I cannot recommend highly enough just using the proper namespaces. i.e.:
That said, to reproduce this without IPython (or pylab):
That's:
And the error:
Essentially, I can reproduce this with Pickle alone, so this isn't a IPython or a Dill issue - I'll go ahead and create an issue on matplotlib, and we can close this one. P.S. The |
@pelson: The above issue is really out of scope for |
FYI: this likely has become a lot easier as of #101. |
dump_session() seems to fail when used with ipython notebook set up for inline plots. When the
%matplotlib inline
magic is used you get a traceback resulting inPicklingError: Can't pickle 'RendererAgg' object: <RendererAgg object at 0x42a2bb8>
and when using the
--pylab=inline
option at start up you get a traceback resulting inPicklingError: Can't pickle <class 'matplotlib.axes.AxesSubplot'>: it's not found as matplotlib.axes.AxesSubplot
Using Dill 0.2a.dev, ipython 1.1.0
The text was updated successfully, but these errors were encountered: