rossant / ipycache

Defines a %%cache cell magic in the IPython notebook to cache results of long-lasting computations in a persistent pickle file
BSD 3-Clause "New" or "Revised" License
138 stars 35 forks source link

Allow to save cache at arbitrary location #3

Closed mpelko closed 11 years ago

mpelko commented 11 years ago

This magic is just what I was looking for in my workflow. One thing I would like to see is being able to save the cache file to arbitrary location, not necessarily to the folder with the notebook.

Simply trying to input the file name with the full path didn't work.

I don't know how far you wanted to go with this magic, but given its usefulness to my own work, I would be happy to contribute myself.

rossant commented 11 years ago

I've been looking for something like this for a long time as well, so I just decided to do it myself! The code is fundamentally really simple: cPickle + if statement! :)

I haven't started to use this magic extensively yet, but I will pretty soon. The more I (and others) will use it, the more I'll find things to improve.

Let me 1) check why it does not work with full paths and 2) try to add an option to choose the folder.

Of course, contributions are more than welcome and I'd happy to review pull requests!

rossant commented 11 years ago

Simply trying to input the file name with the full path didn't work.

Could you give a failing example along with the error message?

rossant commented 11 years ago

OK, I added a --cachedir option with the cache location. You can specify a default directory in the IPython configuration file in your profile (typically in ~/.ipython/profile_default/ipython_config.py) by adding the following line:

c.CacheMagics.cachedir = "/path/to/mycache"

Could you please try it and tell me if that works for you?

mpelko commented 11 years ago

It works. Moreover it would have probably worked before, if I'd only spell my location correctly. Sorry for that. The default directory is a very useful feature as well!

And kudos for the response time.

rossant commented 11 years ago

Good to know!