gregsexton / ob-ipython

org-babel integration with Jupyter for evaluation of (Python by default) code blocks
738 stars 109 forks source link

Support using remote kernels #11

Open nbren12 opened 9 years ago

nbren12 commented 9 years ago

I usually have ipython notebook running on a remote server, which I then connect to over ssh using port forwarding. These are the commands I usually run.

ssh -L 8888:127.0.0.1:8888 myserver
ipython notebook --port 8888 --no-browser

Then, I open 127.0.0.1:8888 in the browser on my local machine. Is there an easy way to do this sort of workflow in ob-ipython?

gregsexton commented 9 years ago

This should be very easy to support. Currently emacs starts the ipython kernel for you and a process which assumes that it is local. When I get time I'll take a look at opening up customisation here to allow running remotely.

smartass101 commented 9 years ago

I think this use case could be simply achieved by setting

(setq ob-ipython-driver-port 8888)

after creating the tunnel. If you want this to be the case only for a given buffer, use setq-local instead.

If you don't want to use the intermediary tunnel, you'd have appply the changes proposed in my PR #29.

However, I think a more flexible approach would be to implement something like an :address header argument or :hostname and :port arguments and these settings would only serve as default settings. This should be reflected by e.g. renaming the to *-default*-.

On a different note, I think a different Customize group (Org Babel IPython) might be more appropriate to make ti easier for the user to find these setting in the group that would logically fit into the hierarchy.

gregsexton commented 9 years ago

I've merged the PR allowing for connecting to a different hostname across all src blocks. Leaving this open to implement the :hostname and :port arguments as suggested. Great idea.

smartass101 commented 8 years ago

I have a working prototype of a solution in PR #39, but please note that at the moment it requires fix for bug in jupyter_client, see the PR for details. It works quite well.

EmperorDali commented 7 years ago

@smartass101 @gregsexton Greg, thank you very much for your work on this module and Ondrej, thank you for your work to try and get remote execution working.

I have a question: Is it possible to connect to a remote ipython using ob-ipython-driver-hostname and ob-ipython-driver-port with the current master branch?

If so, what is the procedure to establish a connection? I've tried the SSH tunnel, together with manually launching jupyter console or driver.py on the remote host, but this didn't work and doesn't seem right - when I execute an ipython block, my local emacs still tries to launch it's own driver.py, since the emacs buffers that run the driver processes aren't running on my machine.

What's the intended purpose of ob-ipython-driver-hostname right now? How do you use it?

dabro commented 7 years ago

Ah, does ob-ipython support this now?

singletS commented 7 years ago

I'm interested in ob-ipython using a remote kernel too.

I'm starting ssh tunnel on local machine, setting ob-ipython-driver-port and verified ob-ipython-driver-hostname. This approach fails when ob-ipython tries to start the local jupyter/ipykernel because the port is already in use.

I'm surely missing something obvious...ideas appreciated!