ENB: The first prototype for #4117: .ipynb support

36 views
Skip to first unread message

Edward K. Ream

unread,
Oct 21, 2024, 1:58:49 PM10/21/24
to leo-editor
Issue #4117 suggests pairing .ipynb files with Leo nodes.
I have put considerable effort into revising the first comment of that issue.

Imo, the acid test is whether Leo can run jupytext as a script.
That's likely because jupytext mostly just munges code.

And success! The following Leonine script works as expected:

from jupytext.cli import jupytext as cli
args = ['--to', 'py:percent', r'c:\test\Notebooks-intro.ipynb']
cli(args)

The output is:

[jupytext] Reading c:\test\Notebooks-intro.ipynb in format ipynb
[jupytext] Updating the timestamp of 'c:\test\Notebooks-intro.py'

Imo, this prototype script demonstrates that issue #4117 is feasible!

Edward

Thomas Passin

unread,
Oct 21, 2024, 3:38:29 PM10/21/24
to leo-editor
I just took a quick look at the jupyter extension(s) for VSCodium/VSStudio. It's very impressive and very easy to read. I don't know why I would use the Jupyter inbrowser interface I used to use (some time ago; I'm very much not updated about Jupyter).  What it lacks and sorely needs, of course, is an outline view.

Thomas Passin

unread,
Oct 21, 2024, 3:56:07 PM10/21/24
to leo-editor
On Monday, October 21, 2024 at 3:38:29 PM UTC-4 Thomas Passin wrote:
I just took a quick look at the jupyter extension(s) for VSCodium/VSStudio. It's very impressive and very easy to read. I don't know why I would use the Jupyter inbrowser interface I used to use (some time ago; I'm very much not updated about Jupyter).  What it lacks and sorely needs, of course, is an outline view.

Turns out there is already an outline view.  It shows all the non-code cells, and it shows cell indentation, which I didn't know you could do with a Jupyter notebook. On the particular notebook I am looking at the top-level markdown cells at the start of the notebook aren't being shown in the outline, which is kind of odd.

Edward K. Ream

unread,
Oct 21, 2024, 4:04:26 PM10/21/24
to leo-e...@googlegroups.com
Thanks for this update. How does the Jupyter plugin play with LeoJS?

Edward

Edward K. Ream

unread,
Oct 21, 2024, 4:07:57 PM10/21/24
to leo-e...@googlegroups.com
On Mon, Oct 21, 2024 at 12:58 PM Edward K. Ream wrote:

Issue #4117 suggests pairing .ipynb files with Leo nodes.
...
And success! The following Leonine script works as expected:

from jupytext.cli import jupytext as cli
args = ['--to', 'py:percent', r'c:\test\Notebooks-intro.ipynb']
cli(args)
...
Imo, this prototype script demonstrates that issue #4117 is feasible!

I make this assertion because the whole project rests on jupytext, which presumably is reliable because it has many users. Everything else is a minor detail!

Edward

Thomas Passin

unread,
Oct 21, 2024, 5:41:23 PM10/21/24
to leo-editor
I don't see that it could. And I've now verified that as you would think, you can't reorder cells in the outline pane by dragging them.  You can do that by cut-and-paste or drag-and-drop in the editor view. I'm finding that tricky though, in terms of where it will end up.

Edward K. Ream

unread,
Oct 21, 2024, 6:26:22 PM10/21/24
to leo-e...@googlegroups.com
On Mon, Oct 21, 2024 at 4:41 PM Thomas Passin wrote:

Thanks for this update. How does the Jupyter plugin play with LeoJS?

I don't see that it could. And I've now verified that as you would think, you can't reorder cells in the outline pane by dragging them.  You can do that by cut-and-paste or drag-and-drop in the editor view. I'm finding that tricky though, in terms of where it will end up.

Thanks for your experiments. They are all valuable.

Edward
Reply all
Reply to author
Forward
0 new messages