treebeardtech / nbmake

📝 Pytest plugin for testing notebooks
https://pypi.org/project/nbmake/
Apache License 2.0
179 stars 18 forks source link

Prevent `FileNotFoundError:` when reading an external file. #91

Closed TomBerton closed 1 year ago

TomBerton commented 1 year ago

Is your feature request related to a problem? Please describe. When running pytest --nbmake on a .ipynb file that has a path to an external file within the directory causes a FileNotFoundError: to occur. However, if the file is from a URL the test is completed.

Describe the solution you'd like Be able to import an external file and read it with pd.read_csv() for example so the test can be completed.

Describe alternatives you've considered This is not an issue using in nbconvert with the Python API interface, but nbmake is better in the command line than nbconvert.

Additional context

alex-treebeard commented 1 year ago

Hi @TomBerton thanks for the report.

I reckon this issue stems from the fact that nbmake sets the current working directory to the notebook's directory.

We did this to replicate the behaviour of running a notebook through the UI.

Our options apparently are to either (a) change the paths in your notebooks to ensure they can be found or (b) have a command line parameter to set the working directory to something else e.g. --nbmake-cwd=.

Keen to hear what your take is on this.

alex-treebeard commented 1 year ago

Closing this one as stale, feel free to re-open it if still impacting.