nbdime
nbdime copied to clipboard
Export nbdiff-web HTML from command line
Is it possible to export the HTML difference generated by the in-notebook "Export" button directly from the command line (without having to manually interact with the application GUI). If not, would this be difficult to implement as a feature?
The use case is:
- A large number of notebooks containing plots need to be re-run after a change to the underlying source code is made, and diffs calculated
- The notebooks which have changed are then inspected visually
If we have a static HTML view of the difference we can automate the process of filtering the notebooks which have not changes. Additionally, having a fixed copy of the HTML difference for future reference is useful it itself.
Thank you
This would also make the diff more usable in various CI scenarios
Sorry, I could swear I wrote an answer to this. It must have gotten lost somewhere..
The current export button was added as a minimal implementation to get this functionality. What you are asking is not currently possible, but should be possible to build. However, it would require one of these two dependencies:
- Either a headless browser to run the JS for generating the HTML DOM from the diff.
- Or node.js with jsdom package for the same purpose.
Another alternative is to save the diff as a self-contained, dynamic HTML page, i.e.
- The HTML template rendered out, with the diff in JSON format in the page.
- The nbdime JS to convert the diff to DOM (either embedded in the doc, or as a side-by-side .js file).
The final alternative is to rewrite the diff to DOM logic in Python. This is not something that I will do at least, but I'd welcome any PRs, given they come with a commitment to help maintain the code.
I'm good with either of the first two alternatives. Given enough time, I guess both could be implemented, with a flag to choose between them.
Thoughts on the alternatives? (CC @minrk)
The second option is probably the simplest to implement and maintain, if not the nicest in principle. Given our current circumstances, I'd probably go with that.
@vidartf or @minrk , any update on this issue? My team would greatly benefit from this added functionality.
@Synergist I'm not in a position where I can spend the time on this myself in the near future, but I would be happy to help anyone who would be willing to take this on!
This would be hugely useful for me as well, unfortunately I am not familiar enough with Python or Jupyter projects to help.
My use case is to run this tool in a CI pipeline as well. It's very difficult to use currently as it requires us to spin up a lot of nbdime docker containers to display diffs.
Is there any progress on this? If not I will be interested in contributing to this. If someone is willing to pair/review I would appreciate
I'm willing to help with review, and helping out along the way 👍
#552 should solve this
@vidartf I would appreciate your code review and your feedback
Hi, I just posted a minimal PR that would let people address this issue without having to fork or patch nbdime's source code (or even change the default template): https://github.com/jupyter/nbdime/pull/744 In my PR description, I included a link to a gist showing an example of how this can be done with the PR.