dccsillag / magma-nvim

Interact with Jupyter from NeoVim.
GNU General Public License v3.0
988 stars 50 forks source link

Ability to Connect to already running Kernels #69

Closed usmcamp0811 closed 1 year ago

usmcamp0811 commented 1 year ago

I am working on adding the ability to connect to already running Kernels. My main motivation for this because the output window gets stuck and makes me have to restart my nvim session (effectively restarting my Kernel). This is a bit frustrating... so I thought I'd add the ability to start the kernel independently.

Start a Kernel

jupyter console --kernel=julia-1.8 -f /tmp/julia.json

in nvim connect to it by :MagmaInit /tmp/julia.json

Currently this works BUT there are two big problems I am facing with this.

  1. You have an error check to see if there's missed output from Jupyter. If you use the external console it will trip this.. I'm still trying to understand whats going on there so I can modify things to not trip..
  2. Seems if you close nvim the kernel still closes. I am not sure if this is a "feature" of Jupyter or if you have some dead man switch somewhere.
usmcamp0811 commented 1 year ago

Think this relates https://github.com/dccsillag/magma-nvim/issues/57

usmcamp0811 commented 1 year ago

Figured out this will also work for connecting to remote Jupyter sessions..

Relates: https://github.com/dccsillag/magma-nvim/issues/22

On Remote

jupyter console --kernel julia-1.7 --ip 10.8.0.105 -f /tmp/remote-julia.json

On Local

scp 10.8.0.105:/tmp/remote-julia.json /tmp/remote-julia.json

In Nvim

:MagmaInit /tmp/remote-julia.json
artkpv commented 1 year ago

That's an exciting feature! I wonder if Magma can work with Google Colab then? There is this tool to run VS Code in Google Colab, https://github.com/abhishekkrthakur/colabcode. If it is possible to connect Magma to it also?

usmcamp0811 commented 1 year ago

I'm just leveraging a feature that is already a part of Jupyter. I don't know.. maybe with some hacking.. I've never used Colab. If its built on top of Jupyter then that would make it easier. If it is its own thing, then that would probably be a big overhaul, because Magma is seemingly just hooking into the Jupyter API..

WhiteBlackGoose commented 1 year ago

Looks trivial as hell to be honest https://github.com/abhishekkrthakur/colabcode/blob/master/colabcode/code.py

damn... if I find time I'll try to merge this PR into my own fork and see if that works XD, good job

WhiteBlackGoose commented 1 year ago

Idk if colab works, but I find this feature very useful lol, thanks FWIW I maintain my fork of magma with last three PRs merged in, so anybody can hop onto it

volkswagenfeature commented 1 year ago

I've been working on a nix script to add Magma to nixOS declaratively, and this is going to be a life-saver. Now I don't have to mess with packaging all the other kernels. Thanks so much for your work!

WhiteBlackGoose commented 1 year ago

Thank you!