I am trying out @jupytext but having some issues.

Leo is build 4e4dba800c
jupytext is installed.
I downloaded a sample jupyter file.

The procedure from above:




*- Create the x.ipynb file in Jupyter.- Create the @jupytext x.ipynb node 
in Leo, without saving the outline.- Populate the @jupytext x.ipynb node 
using refresh-from-disk.refresh-from-disk will put the entire file into the 
root @jupytext node. You can then create organizer nodes as you like. 
Saving the outline will update x.ipynb. After that, everything will just 
work.*


Followed the procedure using the sample file:
Created a node with headline:
@jupytext N://leo//Jupyter//Plotting_with_Matplotlib.ipynb

Populate the @jupytext x.ipynb node using refresh-from-disk (Rt-click over 
node > refresh-from-disk) 

Received a message in Leo log pane:
*NotSupportedNBFormatVersion: Notebooks in nbformat version 3.0 are not 
supported by Jupytext. Please convert your notebooks to nbformat version 4 
with 'jupyter nbconvert --to notebook --inplace'*

Converted the file to version 4:
>jupyter nbconvert --to notebook --inplace Plotting_with_Matplotlib.ipynb
[NbConvertApp] Converting notebook Plotting_with_Matplotlib.ipynb to 
notebook
[NbConvertApp] Writing 86618 bytes to Plotting_with_Matplotlib.ipynb

I assume the conversion has succeeded.
Open Leo and get log pane message "updating: 
N:/leo/Jupyter/Plotting_with_Matplotlib.ipynb"
The node is empty. However when I try to populate the @jupytext x.ipynb 
node using refresh-from-disk I still have a node with no body text.

Starting Leo again from console I have a message in console (not log pane):

*"updating: N:/leo/Jupyter/Plotting_with_Matplotlib.ipynbread_into_root 
Invalid external file: N:/leo/Jupyter/Plotting_with_Matplotlib.ipynb"*

For me, refresh-from-disk does not put the entire file into the root 
@jupytext node.
Am I doing something wrong?

On Saturday, October 26, 2024 at 11:42:21 PM UTC+11 Edward K. Ream wrote:

> Many thanks for all your excitement and kind words. I share that 
> excitement. @jupytext may be Leo's most important addition since @clean.
>
>
> If I understand correctly, the remaining rough edges involve creating 
> .ipynb files and their corresponding @jupytext nodes.
>
>
> *Creating .ipynb files in Jupyter*
>
>
> We can sidestep problems creating .ipynb files as follows:
>
>
> - Create the x.ipynb file *in Jupyter*.
>
> - Create the @jupytext x.ipynb node in Leo, *without* saving the outline.
>
> - Populate the @jupytext x.ipynb node using refresh-from-disk.
>
>
> refresh-from-disk will put the entire file into the root @jupytext node. 
> You can then create organizer nodes as you like. Saving the outline will 
> update x.ipynb. After that, everything will just work.
>
>
> *Creating .ipynb files in Leo*
>
>
> Naturally, we want to create .ipynb files safely from within Leo. Imo, Leo 
> should write @jupytext x.ipynb as follows. There are two cases to consider:
>
>
> *Case 1: x.ipynb exists*
>
>
> This is the easy case. Just create an *empty *@jupytext x.ipynb node. As 
> usual, when you save the outline Leo will warn that the corresponding 
> .ipynb file exists. You should *not* overwrite the file but instead use 
> refresh-from-disk. 
>
>
> *Case 2: x.ipynb does not exist*
>
>
> When x.ipynb does not exist, it's slightly more challenging for Leo to 
> create a valid .ipynb file. There are two sub-cases to consider:
>
>
> 1. If the @jupytext tree is *completely *empty, Leo should create a valid 
> .ipynb file. That is, the file should contain nothing but the *Jupyter 
> prefix*. Rather than hard-coding this prefix, Leo should use the contents 
> of *@data jupyter-prefix*.
>
>
> 2. Otherwise (the @jupytext tree contains text), Leo should write the 
> @jupytext tree, possibly with a warning that creating an .ipynb file by 
> hand isn't a good idea.
>
>
> *Summary*
>
>
> - Creating .ipynb files in Jupyter just works now.
>
> - Leo can easily create valid .ipynb files from *empty *@jupytext trees.
>
> - Leonistas should avoid creating .ipynb files by hand, that is, by saving 
> non-empty @jupytext trees.
>
>
> I welcome all your comments and suggestions.
>
>
> Edward
>
>

-- 
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 visit 
https://groups.google.com/d/msgid/leo-editor/f1bc2e3c-ea47-4724-aba3-5e5c2088d044n%40googlegroups.com.

Reply via email to