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
139 stars 35 forks source link

Automatic detection of cell changes #30

Closed TyberiusPrime closed 9 years ago

TyberiusPrime commented 9 years ago

This patch detects when a cell changed and when the set of variables changed (See #27 )

Cell change is unfortunatly done on hashed contents - no access to python byte code at this level, which could prevent some unnecessary recalculations.

There is no option for this because it will trip people up and lead to inconsistent data. Better safe (recalc) then sorry (work with wrong data).

So long!

TyberiusPrime commented 9 years ago

Hm. I'm not sure why the travis build fails - tests locally did suceed.

ihrke commented 9 years ago

nice work, thanks so much! I checked and the failing travis build is due to some changes in ipython (we run some notebooks through an ipython runner which appears to be broken by the changes). What about a global option for enabling/disabling the automatic recalculations? I can imagine one or two scenarios where you do not want to recalculate (say you added a comment to a cell or re-indented a line) and people might be annoyed by a lengthy recalculation based on this.

ihrke commented 9 years ago

just realized that there appear to be issues with your patch for python 3.

ERROR: test_ipycache.test_cache_1
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/virtualenv/python3.3.5/lib/python3.3/site-packages/nose/case.py", line 198, in runTest
    self.test(*self.arg)
  File "/home/travis/build/rossant/ipycache/test_ipycache.py", line 93, in test_cache_1
    ip_user_ns=user_ns, ip_run_cell=ip_run_cell, ip_push=ip_push)
  File "/home/travis/build/rossant/ipycache/ipycache.py", line 239, in cache
    cell_md5 = hashlib.md5(cell).hexdigest()
TypeError: Unicode-objects must be encoded before hashing
TyberiusPrime commented 9 years ago

Seems easily fixable but I'm traveling right now. Could habe sworn I ran the tests with python3...

Anyhow we will nee test case with non ASCII data.

ihrke commented 9 years ago

Hi, I fixed the python3 tests in #31