mirror of
https://github.com/vale981/emacs-jupyter
synced 2025-03-05 07:41:37 -05:00
Refactor org-babel-jupyter-initiate-session-by-key
This commit is contained in:
parent
b6cfb0aac1
commit
ff47cc6812
1 changed files with 6 additions and 5 deletions
|
@ -144,7 +144,7 @@ the header variables in PARAMS."
|
||||||
(current-buffer)))))
|
(current-buffer)))))
|
||||||
|
|
||||||
(defun org-babel-jupyter-initiate-session-by-key (session params)
|
(defun org-babel-jupyter-initiate-session-by-key (session params)
|
||||||
"Return the `jupyter-repl-client' for SESSION.
|
"Return the `jupyter-repl-client' buffer for SESSION.
|
||||||
If SESSION does not have a client already, one is created based
|
If SESSION does not have a client already, one is created based
|
||||||
on SESSION and PARAMS. If SESSION ends with \".json\" then
|
on SESSION and PARAMS. If SESSION ends with \".json\" then
|
||||||
SESSION is interpreted as a kernel connection file and a new
|
SESSION is interpreted as a kernel connection file and a new
|
||||||
|
@ -153,8 +153,9 @@ based on the `:kernel' parameter in PARAMS which should be either
|
||||||
a valid kernel name or a prefix of one. The first kernel that is
|
a valid kernel name or a prefix of one. The first kernel that is
|
||||||
returned by `jupyter-find-kernelspecs' will be used."
|
returned by `jupyter-find-kernelspecs' will be used."
|
||||||
(let* ((kernel (alist-get :kernel params))
|
(let* ((kernel (alist-get :kernel params))
|
||||||
(key (concat session "-" kernel)))
|
(key (concat session "-" kernel))
|
||||||
(oref (or (gethash key org-babel-jupyter-session-clients)
|
(client
|
||||||
|
(or (gethash key org-babel-jupyter-session-clients)
|
||||||
(let ((client (if (string-suffix-p ".json" session)
|
(let ((client (if (string-suffix-p ".json" session)
|
||||||
(connect-jupyter-repl session)
|
(connect-jupyter-repl session)
|
||||||
(run-jupyter-repl kernel))))
|
(run-jupyter-repl kernel))))
|
||||||
|
@ -170,8 +171,8 @@ returned by `jupyter-find-kernelspecs' will be used."
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(remhash key org-babel-jupyter-session-clients))
|
(remhash key org-babel-jupyter-session-clients))
|
||||||
nil t))
|
nil t))
|
||||||
(puthash key client org-babel-jupyter-session-clients)))
|
(puthash key client org-babel-jupyter-session-clients)))))
|
||||||
buffer)))
|
(oref client buffer)))
|
||||||
|
|
||||||
(defun org-babel-jupyter-initiate-session (&optional session params)
|
(defun org-babel-jupyter-initiate-session (&optional session params)
|
||||||
"Initialize a Jupyter SESSION according to PARAMS."
|
"Initialize a Jupyter SESSION according to PARAMS."
|
||||||
|
|
Loading…
Add table
Reference in a new issue