[IPython-User] Strip output from IPython notebook.

Matthias BUSSONNIER bussonniermatthias@gmail....
Wed Sep 11 03:12:14 CDT 2013

Le 11 sept. 2013 à 09:17, Michael McNeil Forbes a écrit :

> Hi Everyone,
> Over the years there have been lots of discussions about stripping output from IPython notebooks for the purpose of version control.  It is really not clear to me that there is a definitive way to do this, so I asked this as a question on stackoverflow.
> http://stackoverflow.com/questions/18734739/using-ipython-notebooks-under-version-control
> I think that the trail of issues/PRs lead to PR 4175: "nbconvert: Jinjaless exporter base", but it is not completely clear to me.  Could someone in the know please chime in and either provide a definitive answer, or indicate which issue/PR one should wait on before looking for the final solution?

Yes, jinjaless exporter will help, by giving an API that can be used to **for example** 
to strip output or run a notebook headless.

Diffing will still be hard. Working on that, but python difflib does some weird stuff :

Working on difflib 2 before going further with that.

What you are looking for are git clean and smudged filter that apply a transformation 
when staging (clean) and checking (smudge) files to/from the index. it does not require
jinjaless exporters, you just have to walk json by yourself. it will just be eased by #4175.

Bind strip output to (stage/clean), rerun headless to (checkout/smudged) and you get what you ask, 
ie a repo without output, but CWD with ipynb files with output. 

I personally would like a ipynb backend where ipynb are full git repo.
eg, each cell/output a file + an index file that tells how to "rebuild" the ipynb from this folder.

It might or might not make sense to you.

In any case I don't think there would be a final solution that came from IPython itself. 
We provide tools, but the more is external to IPython the better. Seeing the huge amount 
of transformation that people wan tho do on notebook at save time we cannot offer options
for all, so at some point we will have a post save/pre-load hook. Or you can already 
write your own backend to save files. It will be eased by nbconvert, but it will most probably 
not be built-in.


More information about the IPython-User mailing list