There are two issue that I have with iPython / Jupyter notebooks where Leo can be of immense help:
The notebooks are giant JSON blobs, which makes version control painful, I have ad-hoc scripts to break these blobs into an outer skeleton file, and individual files for each cell and to merge them back. This is the kind of thing that Leo handles easily with a node tree. Jupyter itself is a horrible code editor -- I end up using whatever else is available -- textedit, xed, pico, emacs, vi, or, ... leo! The thing I like about Jupyter, more than plain iPython notebooks, is that it runs multiple languages -- Julia, R, and Python with seamless integration of input/output and workspace variables between input and output cells. The graphics support in output cells is outstanding. Other languages like bash, yaml, and elixir are also supported -- either natively, or through plugins. In my world there is no single-language solution, and both code and data need version control. Summary: I support Leo / JuPyteR integration, whether it is hosted by Jupyter or by Leo. On Friday, October 18, 2024 at 9:42:14 AM UTC-4 Edward K. Ream wrote: > This Engineering Notebook post rethinks what Leo's IPython bridge (in > *leoIPython.py*) must be. > > Leo's IPython bridge has likely not worked for years. Imo, the bridge has > never been much more than a toy. As a result, I feel free to re-imagine > everything about Leo's relationship to IPython. > > > *Goals and requirements* > > *I'll retire leoIPython.py unless Leo can become an easy-to-use IPython > notebook. * > > - Leo and IPython must run without blocking each other. > - IPython must have access to c, g and p. > > *Managing event loops* > > As an experiment, I tried running this Leonine script: > > import IPython > IPython.embed() > > As expected, this script starts IPython in the console window from which > Leo launched. And IPython does have access to c, g and p! > > In [1]: c > Out[1]: Commander 1439643722256: 'c:/Repos/leo-editor/leo/core/leoPy.leo' > In [2]: g > Out[2]: <module 'leo.core.leoGlobals' from > 'C:\\Repos\\leo-editor\\leo\\core\\leoGlobals.py'> > In [3]: p > Out[3]: <pos 1439662055744 childIndex: 6 lvl: 0 key: 1439726600784:6 embed> > > Alas, Leo hangs until IPython quits. So more work is needed :-) > > *Managing namespaces* > > A new Leo command, *execute-ipython-script*, should execute p.b in a > namespace that includes all names known to the running IPython instance. > > Similarly, IPython must have access to c, g and p *without *using embed. > > *Packaging* > > Leo's present *--ipython* command-line arg starts Leo in a ipython > console window. I would like to retire this arg: it's clumsy and adds > nothing essential. > > Instead, a new Leo command, say *launch-ipython*, would: > > - Exit with a warning if importing ipython fails. > - Launch (once) IPython in the console from which Leo was launched. > > *Summary* > > Leo's IPython bridge is little more than a toy. Worse, leoIPython.py has > not worked for years. I shall retire leoIPython.py unless Leo can become a > straightforward, easy-to-use IPython notebook. This notebook must: > > - block neither IPython nor Leo. > - give IPython access to c, g and p. > - have an execute-ipython-script command. > > It remains an open question whether these goals are attainable. I have > hopes: IPython's API (fully accessible from Leo) has many features relating > to embedding IPython into applications. > > All comments and questions are welcome. > > Edward > > P.S. Running Leo from Leo's bridge is not the answer. We could avoid > clashing event loops by embedding Leo's bridge (in *leoBridge.leo*) into > IPython. But giving IPython access to Leo via Leo's bridge would add almost > nothing to IPython! > > EKR > -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/leo-editor/080d9397-8eae-4e92-a0df-273537bb24cen%40googlegroups.com.
