Does anyone have any good tools for this that preserve the visuals of the Notebooks.
My approach has always been rendering the files as .py without the cell outputs and comparing which is a big PITA.
Anyone have any advice?
1–10 of 30 posts
Does anyone have any good tools for this that preserve the visuals of the Notebooks.
My approach has always been rendering the files as .py without the cell outputs and comparing which is a big PITA.
Anyone have any advice?
You can prettify it via "python3 -m json.tool" for example. Then you have a structure that you can diff via your favorite diff tool.
What is a pita about it?
http://timstaley.co.uk/posts/making-git-and-jupyter-notebook...
One option would be to start a policy to always “restart and clear output” before saving. This cleans the output cells and makes the .ipynb files diffable. Just happens to also make them nice for storing in version control.
Another option would be to work in pure python files in the first place, and only use Jupyter after the fact. The close brother to Jupyter is the Spyder IDE, which gives you most of the benefits of quick visual outputs, but also has a nice python debugger built in.
https://github.com/mwouts/jupytext/blob/main/docs/paired-not...
It works both ways, it can update the .py file each time you save the notebook, or you can edit the .py file and have the jupytext command line tool update the .ipynb.
You can use jupytext to maintain dual .py/.ipynb representation of notebooks and keep both versions in sync: https://github.com/mwouts/jupytext/blob/main/docs/paired-not... It works both ways, it can update the .py file each time you save the notebook, or you can edit the .py file and have the jupytext command line tool update the .ipynb.
There is https://nbdime.readthedocs.io/en/latest/ , although I haven't used it personally to know how good it is.
But as another commenter said, when I got to the point of needing to diff my notebooks, I realized that I could move some of the code into separate python files.
If you're a business analyst, one use case is if you need to process some data e.g. every quarter, but the data changes a bit every time so you need to update the approach slightly (e.g. data structure changes, new mapping rules). With nbdiff it's easy to keep track of changes while having some helpful visualizations in the same file.