by kenward · 5y ago · 0 comments
The closest thing that we've found has been to use the notebook percent format in a simple .py file [0][1]. It plays with git much nicer than an .ipynb and it is still interactive enough for rapid prototyping. However, it would be nice to have some first-class support from Jupyter on this.
[0] https://jupytext.readthedocs.io/en/latest/formats.html?highl...
[1] https://code.visualstudio.com/docs/python/jupyter-support-py
However, I recently started using VSCode Insiders the preview release of VSCode, which has amazing support for Jupyter notebooks in the editor. You can use your normally configured linters, auto-formatters, vi-mode keyboard shortcuts (major selling point for me). You even get legible, cell-aware diffs when comparing in git. Now, the edit/git workflow for .ipynb files is so close to parity I've stopped caring whether code is in a proper Python module or not, and I almost never run Jupyter Notebook or Jupyter Lab in the browser.
In some ways this is a loss, because it's nice to have project-wide linting and other tooling that only work with .py files, but using `%run` was always an imperfect abstraction. By default, `%run` executes modules in a new module namespace which is then copied over, so it's not exactly "paste into Jupyter" unless you do `%run -i`. Even then, it's limited by running all at once. Every cell in a typical Notebook is effectively a button that runs an `exec()` statement, and you can't achieve those semantics by calling Python functions.
That's an interesting solution. I believe this is similar to what Joel Grus does [0], except %s/jupyter/ipython.
Pity Emacs is not the best on-boarding experience.
[0] https://github.com/mwouts/jupytext/blob/master/docs/paired-n...
Real, working code gets checked in to a repository. The only reason to go back to an old notebook after that point is maybe to see how you may have experimented with or poked at some data.
And apart from that, we have a normal github component to load your code from a github repository: https://nextjournal.com/help/github
FWIW my team uses bitbucket and the PR experience is significantly worse than github/gitlab unfortunately.