Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Add the option to skip output cells when saving. #3291

wants to merge 2 commits into


None yet
7 participants

filmor commented May 8, 2013

To allow notebooks to be put under proper version control it is very sensible to remove the variable but “non-source” parts, the output cells (i.e. massive base64-encoded pngs) and prompt numbers.


Carreau commented May 8, 2013

Wouldn't this be more appropriate as a git commit hook or something along ?

The goal of the ipynb format is to capture output and prompt number for conversion with nbconvert for example, or sharing with nbviewer (notebook shared with nbviewer without output are really desapointing imho).

But I do understand the wish to have it. Maybe the ability to have a post save hook is what you would like.
It could for example run a script that store the stripped version in another directory, and could also cover the need for the --script option.


minrk commented May 8, 2013

a generic hook is probably a better approach. I don't like the way --script works, and I don't think adding a skip-outputs flag to nbformat is something we should do.


tkf commented May 9, 2013

@filmor FYI you can strip output parts using nbstripout.py script in the nbconvert repo:


filmor commented May 9, 2013

@minrk I'm fully for a more generic approach, I'll prepare a proposal.

@tkf Stripping out the output data automatically is not the problem, but the whole reason I want this behaviour is that I want to be able to diff notebook files properly before committing them :) (i.e. the normal git workflow)


ellisonbg commented May 9, 2013

A few comments:

  • git related things really should be done through git hooks.
  • In general notebook transformations should be done using nbconvert. Once it is merged, the .py format should be removed from nbformat entirely.

I think we need to wait until nbconvert is in good shape and merged into IPython before we think about solving these issues. I would like to close this PR and open an issue to track these things. How do people feel about that?


tkf commented May 10, 2013

@filmor You can write a few lines of script to copy notebooks to a git repository and strip outputs when there is a change in notebook directory. This is what I do. But I do agree that if user can hook functions on save event, it would simplify this kind of stuff.

@ellisonbg I think what @filmor wants is to run some action even before commiting notebook, meaning that there aren't any git event to hook at that point (or are there?)


ellisonbg commented May 10, 2013


filmor commented May 10, 2013

The filter attribute seems more suitable. I'll close this know.

@filmor filmor closed this May 10, 2013

@filmor filmor deleted the filmor:dont-save-output branch May 10, 2013


tkf commented May 10, 2013

@ellisonbg I mean even before commit occurs. For example, what can you use if you want to strip off output before running git diff?


janschulz commented May 10, 2013

@filmor Thanks for the idea about clean/smudge filters! That works perfectly for this!

@tkf Did you find a solution to this? I am looking for a way to keep the output, but still show nice diffs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment