mirror of
https://github.com/vale981/emacs-jupyter
synced 2025-03-04 23:41:37 -05:00
Add jupyter-read-connection
* jupyter-base.el (jupyter-read-connection): New function. * jupyter-kernel-process-manager.el (jupyter-start-kernel) [jupyter-command-kernel]: Use it.
This commit is contained in:
parent
c36f6fd63a
commit
6be4f79ab3
2 changed files with 26 additions and 8 deletions
|
@ -529,6 +529,23 @@ Note only SSH tunnels are currently supported."
|
|||
(jupyter-make-ssh-tunnel lport maybe-rport server remoteip)))
|
||||
else collect maybe-rport)))))
|
||||
|
||||
(defun jupyter-read-connection (conn-file)
|
||||
"Return the connection information in CONN-FILE.
|
||||
Return a property list representation of the JSON in CONN-FILE, a
|
||||
Jupyter connection file.
|
||||
|
||||
If CONN-FILE is a remote file, possibly create an SSH tunnel
|
||||
between the localhost and the kernel on the remote host where
|
||||
CONN-FILE lives. The returned connection info. will reflect
|
||||
these changes.
|
||||
|
||||
See `jupyter-tunnel-connection' for more details on creating
|
||||
tunnels. For more information on connection files, see
|
||||
https://jupyter-client.readthedocs.io/en/stable/kernels.html#connection-files"
|
||||
(if (file-remote-p conn-file)
|
||||
(jupyter-tunnel-connection conn-file)
|
||||
(jupyter-read-plist conn-file)))
|
||||
|
||||
;;; Helper functions
|
||||
|
||||
(defun jupyter-canonicalize-language-string (str)
|
||||
|
|
|
@ -151,12 +151,13 @@ argument of the process."
|
|||
:wait-form (and (process-live-p (oref kernel process))
|
||||
(goto-char (point-min))
|
||||
(re-search-forward "Connection file: \\(.+\\)\n" nil t))
|
||||
(let* ((conn-file (match-string 1))
|
||||
(remote (file-remote-p default-directory))
|
||||
(conn-info (if remote (jupyter-tunnel-connection
|
||||
(concat remote conn-file))
|
||||
(jupyter-read-plist conn-file))))
|
||||
(oset kernel session (jupyter-session
|
||||
(oset kernel session
|
||||
(let ((conn-info (jupyter-read-connection
|
||||
(concat
|
||||
(save-match-data
|
||||
(file-remote-p default-directory))
|
||||
(match-string 1)))))
|
||||
(jupyter-session
|
||||
:conn-info conn-info
|
||||
:key (plist-get conn-info :key))))))
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue