ploomber / ploomber-engine

A toolbox 🧰 for Jupyter notebooks 📙: testing, experiment tracking, debugging, profiling, and more!
https://engine.ploomber.io
BSD 3-Clause "New" or "Revised" License
59 stars 14 forks source link

execute_notebook `cwd` not working as expected #57

Closed avivajpeyi closed 1 year ago

avivajpeyi commented 1 year ago

i think the cwd is not working outside the pytest env :sweat_smile:

For example, consider the following:

.
├── run_execute_notebook.py
└── some_dir
    └── test.ipynb

run_execute_notebook.py

from ploomber_engine import execute_notebook

DIR = ".some_dir"
IPYNB = DIR + "/test.ipynb"
execute_notebook(IPYNB, IPYNB, cwd=DIR)

some_dir/test.ipynb

#%%
import os
os.getcwd()
#%%
! touch test_file.txt
#%%
import matplotlib.pyplot as plt
plt.figure().savefig('test.png')

Running: python run_execute_notebook.py, the files are not stored in the some_dir but the top dir where python is run...

.
├── run_execute_notebook.py
├── some_dir
│   └── test.ipynb
├── test.png
└── test_file.txt

test_cwd.zip

edublancas commented 1 year ago

thanks for the fix, I'll make a release once the CI passes in master!