32 ms·
nbstripout [1] is my favorite tool for this. Installing it in your Git repo is 2 lines: $ pip install --upgrade nbstripout # install nbstripout bin $ nbstrip
by KerrickStaley 8y ago
nbstripout [1] is my favorite tool for this. Installing it in your Git repo is 2 lines:
$ pip install --upgrade nbstripout # install nbstripout bin
$ nbstripout --install # install Git hook in current repo
Then, any .ipynb files that you check in will have their output stripped in the index (without affecting your working copy).
(Surprised it's not mentioned in the article.)
[1] https://github.com/kynan/nbstripout https://github.com/kynan/nbstripout
- potatohead00 8y agoThis is my current go to solution. It does require the collaborators to also have it installed
- StavrosK 8y agoIf you use CI you can add such things there so any commits that didn't run them fail CI. I do the same with the `pre-commit` utility, it's very very handy for running checks repeatably.
- leblancfg 8y agoThis is great advice, thanks! In practice, do collaborators also need to have it installed?
- analog31 8y agoIn addition to stripping the output, I will advertise a Jupyter trick that has helped me many times: When I'm ready to walk away from a project for a while, or even if I just need a coffee break, I will do "restart and run all cells." This ensures that there is no hidden state that I've forgotten about, and that someone else could run the same notebook without mishap.
- wp381640 8y agoI wonder if it would be easier and/or possible (should be) to just write a filter in jq that strips output, prompt_number and execution_count in each cell