DonJayamanne / vscodeJupyter

Jupyter for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=donjayamanne.jupyter
MIT License
336 stars 34 forks source link

Jupyter: Setting Remote Kernel #26

Open DonJayamanne opened 7 years ago

DonJayamanne commented 7 years ago

From @anjueappen on October 13, 2016 20:40

Is there a way to set a custom IP for accessing a remote Jupyter notebook? Didn't see anything that we could configure, currently.

Copied from original issue: DonJayamanne/pythonVSCode#383

DonJayamanne commented 7 years ago

Unfortunately not yet.

DonJayamanne commented 7 years ago

From @Earthson on October 20, 2016 9:28

Is there a way to connect to existing kernel by %connect_info?

http://jupyter-notebook.readthedocs.io/en/latest/examples/Notebook/Connecting%20with%20the%20Qt%20Console.html#The-Frontend/Kernel-Model

DonJayamanne commented 7 years ago

Unfortunately this isn't supported as of yet and will be looked at for a future release.

DonJayamanne commented 7 years ago

From @mkohram on February 17, 2017 19:15

I would be more than glad to help with getting existing implemented if I could get a couple of pointers where to start. Please let me know.

Earthson commented 7 years ago

Have you ever use Atom's Hydrogen extension? It supports remote kernel with jupyter.

https://atom.io/packages/hydrogen

breathe commented 7 years ago

I use the hydrogen extension quite often but have migrated to vscode for pretty much everything else.

I periodically check to see if vscode Jupiter supports execution in remote kernels yet ... I use a workflow that gives a similar experience as would be achieved with Jupyter notebooks but gets me out of horrible web page text editor land (which I hate)

  1. Sync a directory of files to a server somewhere via a file watching mechanism
  2. Configure a Jupiter kernel on a remote machine with the required packages and set its startup directory to the target from above sync
  3. Connect to remote kernel from 2 with hydrogen

It is a little quirky sometimes but works pretty well. Would love a vscode based alternative

tiangolo commented 7 years ago

Are you sure this isn't available yet?

Try this:

Then in VS Code:

Here's that command in the code repo.

It seems to me like this is an undocumented with an open issue, while the feature seems to be there :smile:


Still, it doesn't have Hydrogen's inline results nor auto-completion.

But it's a lot closer than not being able to connect to a remote server at all.

As a plus, the token can be written right after running the kernel, it doesn't have to be pre-configured, so you don't have to change configurations in the remote server and locally before being able to use it (as with Hydrogen).


Also, I'm not trying to make it a "vim vs emacs", I'm a huge fan of both plugins and the greatly improved experience they provide.

breathe commented 7 years ago

Oh cool -- I'll check it out!

tslaton commented 6 years ago

One of the parameters given by running jupyter notebook --help-all is:

--NotebookApp.ip=<Unicode>
    Default: 'localhost'
    The IP address the notebook server will listen on.

Could that be useful for this purpose?

I've been able to successfully connect to a remote machine (a Google Cloud Platform instance) using the command @tiangolo mentioned, but I haven't yet managed to successfully connect to the same machine using various combinations of settings under the extension's "jupyter.notebook.startupArgs".

I'd really like to get that working so I don't have to enter the ip and token every time I want to connect.

andybrnr commented 6 years ago

Hi all, Currently exploring development solutions for my DS team. While there are lots of positives to a JupyterHub/JupyterLabs, the irritation of saving all notebooks as .py files for version control has me exploring other options. I've been playing with Atom/Hydrogen running remote kernels on AWS, and this seems to be a reasonable solution. There is some awkwardness, though (need to run the remote kernel in a synchronized directory structure to pick up local imports or use sshfs). Any thoughts on similar issues/maturity of using VS Code for doing local development with execution on remote kernels? One issue I've run into so far is that kernel_gateway doesn't seem to work, though tests with notebook server worked ok (had some problems restarting/shutting down kernels, but that might have been a notebook server config issue). Thanks!

puppyapple commented 6 years ago

@tiangolo why i get nothing after typing the url following with entring the token, have tried many times?

tiangolo commented 6 years ago

Sorry for the late response @puppyapple .

When you hit enter it doesn't show any obvious cue telling you if it worked or not. But you get a little new item in the blue status bar at the bottom. It tells you which Python kernel is running.

Then you can select a Python line, hit Ctrl + Shift + p, find the command Jupyter: Run Selection/Line and execute it. It won't show you if it ran or not, only when your code is an expression that results in a value. So, import os won't show anything, my_var = "some text" won't show anything either, but "some text" alone will open the output display and show the printed "some text".