emacs-jupyter / jupyter

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

Can't connect to remote kernel #539

Closed JonatanSahar closed 3 months ago

JonatanSahar commented 4 months ago

Hi, thanks for your amazing work on this! I've been working with your package for a few months now, but have only just tried to connect to a remote kernel. I can connect to it using vscode, and I've printed out the kernel file. I'm connected to the remote server using tramp, which works well, and I've called jupyter-connect-repl, but after a liile while of "Requesting kernel info..." I'm getting:

or: Timeout before idle: #s(jupyter-request "4d804621-ad13-49fa-8960-dddbda4f9d7d" "kernel_info_request" nil #s(jupyter-repl-client jupyter--clients (#) "idle" 1 nil #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data ()) ((closure ((pub-fn closure ((--cl-start-- closure ((--cl-ch-start-- closure ... ... ...) (--cl-ch-put-- closure ... ... ...) (ioloop . #s(jupyter-zmq-channel-ioloop ... #<process zmq<3>> nil ... ... ...)) (kernel-io closure #4 ... ...) (session . #s(jupyter-session ... "509529c1-c668-4874-8998-0fa24a8fd6d9" "b31550d0-0c8c5051987e33519d9d947a")) (channels :shell :iopub :stdin :control)) nil (progn (if ioloop nil ... ... ...) (if ... nil ... ...) ioloop)) (--cl-set-session-- closure ((session . #s(jupyter-session ... "509529c1-c668-4874-8998-0fa24a8fd6d9" "b31550d0-0c8c5051987e33519d9d947a")) (kernel . #s(jupyter-kernel-process #s(jupyter-kernelspec "python" ... nil) #s(jupyter-session ... "509529c1-c668-4874-8998-0fa24a8fd6d9" "b31550d0-0c8c5051987e33519d9d947a") t))) nil (or (setq session ...) (error "A session is needed to connect to a kernel's I/O"))) (shutdown) (hb) (session . #s(jupyter-session (:shell_port 38861 :iopub_port 38693 :stdin_port 39399 :control_port 46513 :hb_port 44553 ...) "509529c1-c668-4874-8998-0fa24a8fd6d9" "b31550d0-0c8c5051987e33519d9d947a"))) (content) (if shutdown (error "Kernel I/O no longer available: %s" (cl-prin1-to-string session)) (let ((val ...)) (cond (... ...) (... ...) (... ...) (t ...))))) (subs subscribers (closure ((pub-fn closure (... ...) (msg) (cond ... ...)) (subs subscribers (closure ... ... ...))) (pub-value) (let ((val ...)) (cond (... ...) (... ...) (t ...)))))) (pub-value) (let ((val (car-safe pub-value))) (cond ((eq val 'content) (let nil (jupyter-pseudo-bind-content pub-fn (car ...) subs))) ((eq val 'subscribe) (let nil (let (... ...) (setcdr v ...)))) (t (let nil (error "Unhandled publisher content: %s" pub-value)))))) (closure ((sub-fn closure ((--cl-stop-- closure ((ioloop . #s(jupyter-zmq-channel-ioloop ... #<process zmq<3>> nil ... ... ...)) (hb)) nil (progn (if hb ...) (if ioloop ...))) (--cl-start-- closure ((--cl-ch-start-- closure ... ... ...) (--cl-ch-put-- closure ... ... ...) (ioloop . #s(jupyter-zmq-channel-ioloop ... #<process zmq<3>> nil ... ... ...)) (kernel-io closure ... ... ...) (session . #s(jupyter-session ... "509529c1-c668-4874-8998-0fa24a8fd6d9" "b31550d0-0c8c5051987e33519d9d947a")) (channels :shell :iopub :stdin :control)) nil (progn (if ioloop nil ... ... ...) (if ... nil ... ...) ioloop)) (--cl-set-ch-group-- closure ((--cl-set-session-- closure ... nil ...) (ch-group :shell ... :iopub ... :stdin ... :control ...) (channels :shell :iopub :stdin :control)) nil (let (...) (setq ch-group ...))) (shutdown) (kernel . #s(jupyter-kernel-process #s(jupyter-kernelspec "python" ... nil) #s(jupyter-session ... "509529c1-c668-4874-8998-0fa24a8fd6d9" "b31550d0-0c8c5051987e33519d9d947a") t))) (action) (cond ((eq action 'interrupt) (let nil (jupyter-interrupt kernel))) ((eq action 'shutdown) (let nil (jupyter-shutdown kernel) (funcall --cl-stop--) (setq shutdown t))) ((eq action 'restart) (let nil (setq shutdown nil) (jupyter-restart kernel) (funcall --cl-stop--) (funcall --cl-set-ch-group--) (funcall --cl-start--))) ((consp action) (let (...) (if ... ...)))))) (sub-content) (if (consp sub-content) (let ((x229 (car-safe sub-content))) (cond ((eq x229 'content) (let (...) (if ... ... ...))) ((eq x229 'subscribe) (let (...) (if ... ... ...))) (t (let nil (error "Unhandled subscriber content: %s" sub-content))))) (let nil (error "Unhandled subscriber content: %s" sub-content))))) #<buffer jupyter-kernel-client-342338> nil ...) (26196 23594 852576 807000) nil nil nil (closure ((pub-fn closure ((id . "4d804621-ad13-49fa-8960-dddbda4f9d7d") (req . #0)) (msg) (cond ((and (progn (or (progn ...) (signal ... ...)) (aref req 6)) (string= (jupyter-message-type msg) "status")) (jupyter-unsubscribe)) ((string= id (jupyter-message-parent-id msg)) (progn (or (progn (and ... t)) (signal 'wrong-type-argument (list ... req))) (let ((v req)) (aset v 7 msg))) (progn (or (progn (and ... t)) (signal 'wrong-type-argument (list ... req))) (let ((v req)) (aset v 8 (nconc ... ...)))) (if (or (jupyter-message-status-idle-p msg) (string= (jupyter-message-type msg) "kernel_info_reply") (string= (jupyter-message-type msg) "shutdown_reply")) (progn (progn (or ... ...) (let ... ...)))) (jupyter-content (cons :parent-request (cons req msg)))))) (subs subscribers (closure ((sub-fn closure ((client . #s(jupyter-repl-client jupyter--clients ... "idle" 1 nil #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data ()) ... #<buffer jupyter-kernel-client-342338> nil ...))) (msg) (let ((channel ...)) (jupyter-handle-message client channel msg)))) (sub-content) (if (consp sub-content) (let ((x229 (car-safe sub-content))) (cond ((eq x229 ...) (let ... ...)) ((eq x229 ...) (let ... ...)) (t (let nil ...)))) (let nil (error "Unhandled subscriber content: %s" sub-content)))))) (pub-value) (let ((val (car-safe pub-value))) (cond ((eq val 'content) (let nil (jupyter-pseudo-bind-content pub-fn (car (cdr pub-value)) subs))) ((eq val 'subscribe) (let nil (let ((a1 (car ...)) (v subs)) (setcdr v (let* (...) (if ... vlist ...)))))) (t (let nil (error "Unhandled publisher content: %s" pub-value)))))) ...)

I've also tried running `jupyter kernel --kernel=python' and connecting to that kernel, but I got the same thing.

Please advise, and thanks again!

JonatanSahar commented 3 months ago

jupyter-connect-sercer-repl is the answer

gmoutso commented 3 months ago

I was going to suggest this to you (but you got there first!). That is, use a running notebook server on the remote that you know "just works" and run kernels and REPLs using that (after an ssh port forward if needed).