emacs-jupyter / jupyter

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

Bug when using elisp to determine the session name #352

Open NightMachinery opened 3 years ago

NightMachinery commented 3 years ago

I am using an elisp function to determine the session names, so that I can easily change the execution machine:

(defvar *night/org-babel-remote* t)
(defun night/org-babel-session-name-get (&optional name)
  (let ((name (or name "s1")))
    (cond
     (*night/org-babel-remote*
      (concat "/ssh:xxx:" name))
     (t name))))

When I use this:

#+begin_src jupyter-julia :session (night/org-babel-session-name-get "j1") :async yes :pandoc t
run(`hostname`)
#+end_src

Two kernel sessions will be created, one with the correct result from the elisp function, and one named *jupyter-repl[julia 1.6.0]-(night/org-babel-session-name-get "j1")*. My guess is that all executions are run in the correct kernel, while *jupyter-repl[julia 1.6.0]-(night/org-babel-session-name-get "j1")* is used for autocomplete etc.

nnicandro commented 2 years ago

Seems to have something to do with org-babel-get-src-block-info and its LIGHT argument. If you run

(alist-get :session (nth 2 (org-babel-get-src-block-info t)))

with point on the source block you'll get the unevaluated session name. Whereas if you change t to nil you get the evaluated name.

NightMachinery commented 2 years ago

@nnicandro commented on Nov 15, 2021, 5:13 AM GMT+3:30:

Seems to have something to do with org-babel-get-src-block-info and its LIGHT argument. If you run

(alist-get :session (nth 2 (org-babel-get-src-block-info t)))

with point on the source block you'll get the unevaluated session name. Whereas if you change t to nil you get the evaluated name.

What fix do you suggest? Should I add an advice around org-babel-get-src-block-info to always use nil?

nnicandro commented 2 years ago

I think I fixed the issue in f178c1c7b8d9a0c0b77e38dc03524db3d2c8288a. Can you see if that works for you?