gregsexton / ob-ipython

org-babel integration with Jupyter for evaluation of (Python by default) code blocks
739 stars 109 forks source link

Have ob-ipython respect :dir #174

Open dangom opened 6 years ago

dangom commented 6 years ago

It seems to me that ob-ipython will respect the :dir header argument when the kernel is started, but won't afterwards. Example:


* Header One
:PROPERTIES:
:header-args: :dir /home/header_one
:END:

#+BEGIN_SRC ipython
import os
os.getcwd()
#+END_SRC

#+RESULTS:
:RESULTS:
# Out[356]:
# text/plain
: '/home/header_one'
:END:

 * Header Two
:PROPERTIES:
:header-args: :dir /home/header_two
:END:

#+BEGIN_SRC ipython
os.getcwd()
#+END_SRC

#+RESULTS:
:RESULTS:
# Out[357]:
# text/plain
: '/home/header_one'
:END:

I was wondering if there are any simple workarounds to overcome this issue? Could one prepend a os.chdir() command if :dir is local and specified upon sending code to the kernel?