emacs-jupyter / jupyter

An interface to communicate with Jupyter kernels.
GNU General Public License v3.0
914 stars 89 forks source link

Locked src_block cells after running dead python sessions #538

Open fraricci opened 1 month ago

fraricci commented 1 month ago

Hi there.

I had the following happening and wanted to know if it's a bug or it's more a misuse of the package on my end.

I have an org document with some src blocks with a remote python session. When that session ends I run that cell by accident, the cell is "locked" and any edits is forbidden. I think this is done using an overlay. Now, since that session does not exist anymore, the connection hangs for a while and I just stop it (C-g). But, the overlay stays and that part of the buffer is not editable anymore.

Now, should I just wait that jupyter-emacs realizes that the session has gone, gets back to me with some message, and unlocks that src block? Or this logic is not implemented yet. Or just be careful not to run cells connected to dead sessions ;-)

What I ended up doing is to remove the overlay manually with an dedicated emacs function with the start and end of that region, but it's pretty annoying.

Any feedback is appreciate.

Thanks

5183nischal commented 1 month ago

I have observed this too but can't reliably recreate on local jupyter sessions.

nnicandro commented 1 month ago

Making a source block non-editable during execution is a new feature that I added so that it would be more obvious that that execution is taking place. There may be some kinks to work out. It does look like some logic needs to be implemented to handle this case and is not a user error.

fraricci commented 1 month ago

Thanks for your clear reply! I actually found this new feature useful and good looking. So, yeah, it just needs some logic to make it editable again in case of issues.

On a similar line, actually, I always wanted to have something in the modeline that makes clear the kernel status, but not sure how to do it.

nnicandro commented 1 month ago

On a similar line, actually, I always wanted to have something in the modeline that makes clear the kernel status, but not sure how to do it.

You can start with something like

(jupyter-org-with-src-block-client
 (equal (jupyter-execution-state jupyter-current-client) "busy"))

But this would only work with point inside a source block. I don't know what would make sense if you wanted this to work outside of a source block since there can be many sessions associated with a single Org file.