[IPython-dev] Prototyping on a plane: Splitting-recombining contents manager

Thomas Kluyver takowl at gmail.com
Tue Jul 14 12:57:32 EDT 2015


On the flight back from Austin yesterday, I got some time to work on an
idea I've had for a while: a contents manager that splits inputs/outputs
and recombines them on load.

In some contexts, you want to version control the code + markdown of a
notebook and not the outputs, which may change more frequently, and may
include big blobs of binary data which VCSs don't handle well. There are
tools available to strip outputs out before committing, but then you lose
the outputs locally as well. And if any collaborator doesn't set up that
tool, they might accidentally commit the outputs.

With this contents manager, when you save a notebook, you get an extra
Whatever.ipynb.clean file, with no outputs or execution_count prompt
numbers. Whatever.ipynb is also saved as normal, with the outputs left
intact.

The idea is that you would commit the .ipynb.clean files, and tell the VCS
to ignore .ipynb files, keeping them as a local cache of the outputs from
running the notebook.

If someone else changes the 'clean' copy in version control, it may no
longer match your local cache. When you open the notebook, the clean copy
is considered authoritative, but it still tries to use information from the
cached 'dirty' copy. It uses difflib to match up code cells that haven't
changed, and reinstates the output from the cache.

The code, and an example notebook with only the clean part in version
control, are here:
https://github.com/takluyver/recombinecm

N.B. Both files will show up the file list, but you need to click the
.ipynb to open the notebook. I'm still thinking about how to make this
neater.

Thomas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20150714/58090d13/attachment.html>


More information about the IPython-dev mailing list