Re: Please try @auto for Jupyter Notebooks

2018-04-10 Thread Edward K. Ream
On Tue, Apr 10, 2018 at 12:15 PM, Terry Brown  wrote:

> ​This may be yet another 2/3 difference.  Try e912eeb67.
>
> Ok, no tracebacks, cool.
>

​Great.  Thanks for the confirmation.

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 leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: Please try @auto for Jupyter Notebooks

2018-04-10 Thread Terry Brown
On Tue, 10 Apr 2018 11:40:36 -0500
"Edward K. Ream"  wrote:

> ​This may be yet another 2/3 difference.  Try e912eeb67.

Ok, no tracebacks, cool.

Cheers -Terry

-- 
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 leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: Please try @auto for Jupyter Notebooks

2018-04-10 Thread Edward K. Ream
On Tue, Apr 10, 2018 at 11:35 AM, Terry Brown  wrote:

Seems to work, but still a Traceback
> ​ [TypeError].
>

​This may be yet another 2/3 difference.  Try e912eeb67.

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 leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: Please try @auto for Jupyter Notebooks

2018-04-10 Thread Terry Brown
On Tue, 10 Apr 2018 11:26:02 -0500
"Edward K. Ream"  wrote:

> >
> > So it loaded, but with the Traceback I just posted.  
> 
> 
> ​Please try fb16c99b9.

Seems to work, but still a Traceback

Leo Log Window
Leo 5.7.2 devel, build 20180408225138, Sun Apr  8 22:51:38 PDT 2018
Git repo info: branch = devel, commit = fb16c99b9aef
Python 3.5.5, PyQt version 5.8.0

Exception running Import_IPYNB
Traceback (most recent call last):

  File 
"/mnt/usr1/usr1/home/tbrown/t/Package/leo/git/leo-editor/leo/core/leoApp.py", 
line 1508, in scanner_for_ext_cb
return scanner.run(s, parent)

  File 
"/mnt/usr1/usr1/home/tbrown/t/Package/leo/git/leo-editor/leo/plugins/importers/ipynb.py",
 line 57, in run
self.import_file(fn, parent)

  File 
"/mnt/usr1/usr1/home/tbrown/t/Package/leo/git/leo-editor/leo/plugins/importers/ipynb.py",
 line 44, in import_file
self.indent_cells()

  File 
"/mnt/usr1/usr1/home/tbrown/t/Package/leo/git/leo-editor/leo/plugins/importers/ipynb.py",
 line 113, in indent_cells
n = to_int(n)

  File 
"/mnt/usr1/usr1/home/tbrown/t/Package/leo/git/leo-editor/leo/plugins/importers/ipynb.py",
 line 83, in to_int
return int(n)

TypeError: int() argument must be a string, a bytes-like object or a number, 
not 'NotebookNode'

-- 
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 leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: Please try @auto for Jupyter Notebooks

2018-04-10 Thread Edward K. Ream
>
> So it loaded, but with the Traceback I just posted.


​Please try fb16c99b9.

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 leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: Please try @auto for Jupyter Notebooks

2018-04-10 Thread Edward K. Ream
On Tue, Apr 10, 2018 at 10:50 AM, Terry Brown  wrote:

> On Tue, 10 Apr 2018 10:49:27 -0500
> Terry Brown  wrote:
>
> > conda says it was installed already.  Current trunk 77b8c7d833 I'm
> > getting
>
> but it did load the file now, so 77b8c7d833 must have helped.
>

​Yeah, python 3 fixes a nasty import problem, so maybe I should back off a
bit about my 2/3 complaints ;-)
​


> So it loaded, but with the Traceback I just posted.
>

​Many thanks for your testing.  I'll fix this asap.

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 leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: Please try @auto for Jupyter Notebooks

2018-04-10 Thread Terry Brown
On Tue, 10 Apr 2018 10:49:27 -0500
Terry Brown  wrote:

> conda says it was installed already.  Current trunk 77b8c7d833 I'm
> getting

but it did load the file now, so 77b8c7d833 must have helped.

So it loaded, but with the Traceback I just posted.

Cheers -Terry

-- 
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 leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: Please try @auto for Jupyter Notebooks

2018-04-10 Thread Terry Brown
On Tue, 10 Apr 2018 10:39:05 -0500
"Edward K. Ream"  wrote:

> On Tue, Apr 10, 2018 at 8:50 AM, Terry Brown 
> wrote:
> 
> p.s. I also got
> > ​[no children] in the @auto node,
> 
> ​You won't get anything if nbformat can't be imported.  I'll attempt a
> clearer warning.
> 
> Edward

conda says it was installed already.  Current trunk 77b8c7d833 I'm
getting

Exception running Import_IPYNB
Traceback (most recent call last):

  File 
"/mnt/usr1/usr1/home/tbrown/t/Package/leo/git/leo-editor/leo/core/leoApp.py", 
line 1508, in scanner_for_ext_cb
return scanner.run(s, parent)

  File 
"/mnt/usr1/usr1/home/tbrown/t/Package/leo/git/leo-editor/leo/plugins/importers/ipynb.py",
 line 57, in run
self.import_file(fn, parent)

  File 
"/mnt/usr1/usr1/home/tbrown/t/Package/leo/git/leo-editor/leo/plugins/importers/ipynb.py",
 line 44, in import_file
self.indent_cells()

  File 
"/mnt/usr1/usr1/home/tbrown/t/Package/leo/git/leo-editor/leo/plugins/importers/ipynb.py",
 line 113, in indent_cells
stack = self.move_node(n, p, stack)

  File 
"/mnt/usr1/usr1/home/tbrown/t/Package/leo/git/leo-editor/leo/plugins/importers/ipynb.py",
 line 239, in move_node
stack = stack[:n]

TypeError: slice indices must be integers or None or have an __index__ method



-- 
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 leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: Please try @auto for Jupyter Notebooks

2018-04-10 Thread Edward K. Ream
On Tuesday, April 10, 2018 at 10:39:07 AM UTC-5, Edward K. Ream wrote:
>
> On Tue, Apr 10, 2018 at 8:50 AM, Terry Brown  
> wrote:
>
> p.s. I also got 
>> ​[no children] in the @auto node,
>>
>
> ​You won't get anything if nbformat can't be imported.  I'll attempt a 
> clearer warning.
>

77b8c7d83 warns (once) if nbformat hasn't been imported and is needed for 
@auto x.ipynb.

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 leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: Please try @auto for Jupyter Notebooks

2018-04-10 Thread Edward K. Ream
On Tue, Apr 10, 2018 at 8:50 AM, Terry Brown  wrote:

p.s. I also got
> ​[no children] in the @auto node,
>

​You won't get anything if nbformat can't be imported.  I'll attempt a
clearer warning.

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 leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: Please try @auto for Jupyter Notebooks

2018-04-10 Thread Edward K. Ream
On Tue, Apr 10, 2018 at 8:48 AM, Terry Brown  wrote:

Traceback (most recent call last):
>
>   File "/mnt/usr1/usr1/home/tbrown/t/Package/leo/git/leo-editor/
> leo/plugins/importers/ipynb.py", line 192, in parse
> nb = nbformat.reads(payload, as_version=4)
>

​Yeah, you have to have nbformat installed.  I'm working on better error
checking as we speak.​  The "real" code just works, but the itsy-bitsy
details are really important in this kind of code.

Rev 8e05a8d43 handles an import mixup that only affects python 2.

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 leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: Please try @auto for Jupyter Notebooks

2018-04-10 Thread Terry Brown
p.s. I also got this in the @auto node,

@nocolor-node

Note: This node's body text is ignored when writing this file.

The @others directive is not required

but no children.  Not necessarily at the same time as the exception,
the above might have come from refresh from disk, whereas the Traceback
was on load of the .leo file.

-- 
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 leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: Please try @auto for Jupyter Notebooks

2018-04-10 Thread Terry Brown
On Tue, 10 Apr 2018 05:40:00 -0700 (PDT)
"Edward K. Ream"  wrote:

> Please, please, give this a try and tell me what you think.  Imo it
> moots a lot of Jupyter-related work on Leo's to-do list.

Well, my aspiration was not a better way to edit notebooks, but a way
to execute code in a (possibly remote) Jupyter kernel, and get back
"rendered" results.

Nonetheless, what you describe sounds very cool so I'll try it :)

In my browser my notebook looks likes:

In [2]: import datetime
In [3]: datetime.datetime.now()
Out[3]: datetime.datetime(2018, 4, 10, 8, 33, 15, 831778)
In [4]: datetime.datetime.now().time()
Out[4]: datetime.time(8, 43, 15, 571086)

seems to be behaving as expected.  I've verified the file's
/home/tbrown/r/Untitled.ipynb

Log output

reading: @auto /home/tbrown/r/Untitled.ipynb
Traceback (most recent call last):

  File 
"/mnt/usr1/usr1/home/tbrown/t/Package/leo/git/leo-editor/leo/plugins/importers/ipynb.py",
 line 192, in parse
nb = nbformat.reads(payload, as_version=4)

AttributeError: 'NoneType' object has no attribute 'reads'

HTH, Cheers -Terry

-- 
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 leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: Please try @auto for Jupyter Notebooks

2018-04-10 Thread Edward K. Ream
On Monday, April 9, 2018 at 9:30:37 AM UTC-5, Edward K. Ream wrote:

Leo now supports @auto for Jupyter Notebook (.ipynb) files far better than 
> I expected two days ago.
>

Yeah, yesterday was Monday, but I'm surprised nobody has commented about 
how awesome this is ;-)

Perhaps a lot of people don't know what I'm talking about.  Here is the 
script, j.bat, that I use. I execute it in a separate console: 

cd c:\test
jupyter notebook %*

The test directory contains the .ipynb files.  I open a new console and 
just type "j".  This starts the Jupyter server, which then opens my web 
browser on a Jupyter "home" page.  This page shows the contents of the test 
folder.  I select my test .ipynb and it appears in another tab.  Simple as 
that.

I can change any cell in Jupyter and save the file.  If the corresponding 
.leo file is running the new code appears in the @auto tree.  Simple as 
that.  I can also change the @auto tree.  The Jupyter web page will (I 
think) eventually reload automatically.  Or I can reload the page myself.  
Simple as that.

Please, please, give this a try and tell me what you think.  Imo it moots a 
lot of Jupyter-related work on Leo's to-do list.

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 leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: Please try @auto for Jupyter Notebooks

2018-04-10 Thread Edward K. Ream
On Monday, April 9, 2018 at 8:37:18 PM UTC-5, Edward K. Ream wrote:

A new command, say insert-md-toc, would be better. It would insert the toc 
> at the cursor.
>

Recent revs replace the @toc hack with the insert-jupter-toc command. 

I spent more than an hour experimenting with what should be allowed in 
urls.  This is quite tricky, and depends on undocumented features of 
Jupyter.  The present code generates toc lines as follows:

line = '%s- [%s](#%s)\n' % (
' '*4*(level-1),
clean_headline(p.h),
clean_headline(p.h.replace(' ','-')))

with:

def clean_headline(s):
# Surprisingly tricky.
# This could remove too much, but better to be safe.
aList = [ch for ch in s if ch in '-: ' or ch.isalnum()]
return ''.join(aList).rstrip('-').strip()

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 leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: Please try @auto for Jupyter Notebooks

2018-04-09 Thread Edward K. Ream
On Monday, April 9, 2018 at 5:03:19 PM UTC-5, Edward K. Ream wrote:


> A few more tweaks are coming
>

Rev 8b2a11ae84 adds support for @toc.  This is a useful hack.

Inserting an @toc in a node causes the writer to insert a table of contents 
(in markdown format) at the start of the node before writing the file.  You 
should then remove the @toc directive, and probably rearrange Leo 
directives as well.

This is just a prototype, but the toc links work in Jupyter!

A new command, say insert-md-toc, would be better. It would insert the toc 
at the cursor.  Maybe tomorrow.

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 leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: Please try @auto for Jupyter Notebooks

2018-04-09 Thread Edward K. Ream
On Monday, April 9, 2018 at 10:02:44 AM UTC-5, Edward K. Ream wrote:

*Summary*
>
> Jupyter integration just keeps getting better and better. Straightforward 
> changes will:
>
> 1. Generate markdown section markup *automatically*, based on outline 
> level and headlines.
>
> 2. Allow code nodes to be indented (in the Leo outline) wherever we like.
>

Done at rev 7447083c7.

Folks, this a *remarkable *level of integration.  It feels Leonine to 
author in Leo (with all of Leo's organizing capabilities) and then render 
or run code in Jupyter.

A few more tweaks are coming, but the code should be usable right now.  For 
example, I test everything by alternating between:

*In Leo*: Loading, changing and saving a .leo file with an @auto node based 
on this file 

.

*In Jupyter*: Loading, changing and saving the resulting .ipynb file.

Please do use the code an report any problems or questions.  Thanks.

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 leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: Please try @auto for Jupyter Notebooks

2018-04-09 Thread Edward K. Ream
On Monday, April 9, 2018 at 9:49:51 AM UTC-5, Edward K. Ream wrote:

The present work seems complete.  Please test and report any problems or 
> missing features.
>

The exporter can write # markup using headline for markdown nodes, and can 
write "leo_markup" metadata for code nodes.  This will allow code nodes to 
be indented anywhere.

*Summary*

Jupyter integration just keeps getting better and better. Straightforward 
changes will:

1. Generate markdown section markup *automatically*, based on outline level 
and headlines.

2. Allow code nodes to be indented (in the Leo outline) wherever we like.

These changes will bring Leo organization to Jupyter notebooks, and will 
make Leo a superior Jupyter authoring tool.

Expect these improvements later today.

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 leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: Please try @auto for Jupyter Notebooks

2018-04-09 Thread Edward K. Ream
On Monday, April 9, 2018 at 9:30:37 AM UTC-5, Edward K. Ream wrote:

I should investigate whether markdown # headlines work in Jupyter.
>

Jupyter does indeed support such titles, and rev 79affcd2d now supports 
them as well.

The present work seems complete.  Please test and report any problems or 
missing features.

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 leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.