by enriquto · 4y ago · 0 comments
For those of you who are similarly affected, you may want to try jupytext. It is a tiny package that converts threeway between ipynb, plain python files (whose comment blocks are interpreted as markdown cells) and plain markdown files (whose code blocks are interpreted as code cells). Moreover, if you have jupytext installed, then jupyter will read and write python and markdown files transparently as notebooks so that you don't need to deal with the stupid ipynb files anymore. This is nice because then you can track the evolution of notebooks easily in git, and your local graybeards can edit notebooks with a plain text editor, with no need of a web browser at all.
Of course, the output cells are not saved, but this was always in bad taste anyway. If you want a nice html with the cell outputs you can run "jupyter nbconvert --execute --to html" from the command line (and yes, it will work with plain python or markdown files if you have jupytext installed).
Why this is not part of jupyter proper is beyond me.
EDIT: regarding nbdev, I would like to learn what are the advantages with respect to the minuscule jupytext thing. I'm particularly concerned by the soundness of the quarto dependency, which is a scary behemoth made by accretion of haskell and javascript.
The fact that everyone I talk to agrees that this format sucks and then turns around and ask us to use yet another formatting tool (jupytext, nvcovert blah blah) is equally vexing.
Rmarkdown (+rstudio) has shown that one can have the cake and eat it too. Ironically, I prefer rstudio for doing exploratory coding with python. Hopefully their recent pivot to more-than-byond-R will save us from this .ipynb mess.
It’s language agnostic (both in name but also cell meta data is yaml instead of r code) and the ecosystem around it already supports a lot of editors.
In defense of ipynb, I really do enjoy that code and output are together. The only place it isn’t nice is in git.
Becoming to "Posit", see https://posit.co where they share their vision for their new future.
Heh. Notice that jupytext is not merely a file format converter. It is a plugin to jupyter that allows it to treat python and markdown files as notebooks. This works both for input and output, with transparent and idempotent round-trips. Once you have this plugin you don't see ipynb files ever again (unless for some bizarre reason you specifically save your notebooks into this format).