jupyter
jupyter copied to clipboard
org-sbe calling a jupyter-python source block returns nil
I want to call a jupyter-python source block using org-sbe.
The source block itself gives a normal output, I can also use CALL, but using org-sbe, which I want to use in a table, just returns nil.
#+NAME: test_jupyter
#+begin_src jupyter-python :session py
5
#+end_src
#+RESULTS: test_jupyter
: 5
#+CALL: test_jupyter()
#+RESULTS:
: 5
#+begin_src emacs-lisp
(org-sbe test_jupyter)
#+end_src
#+RESULTS:
: nil
Using a standard python source block works normally though.
#+NAME: test_python
#+begin_src python
return(5)
#+end_src
#+RESULTS: test_python
: 5
#+CALL: test_python()
#+RESULTS:
: 5
#+begin_src emacs-lisp
(org-sbe test_python)
#+end_src
#+RESULTS:
: 5
I am not really sure though If this is a bug though, or if I am just not using the function correctly.
The problem lies in org-sbe using the return value of org-babel-execute-src-block for its results. org-babel-execute-src-block returns nil when evaluating Jupyter blocks, see org-babel-execute:jupyter (its a mess though).
emacs-jupyter was written so that it has the final say in how to insert results since Org expects results to be relatively simple compared to what is possible with Jupyter.
A way to handle this would be to distinguish between simple and more complex results (e.g. standard output mixed with a graph). For the simple results we can have org-babel-execute-src-block return them so that this usage with org-sbe is possible.
Not sure how much time I will have to look into this in the near future, but I will be glad to help anyone who would like to tackle it.