I have a basic yet annoying file reading issue.
I have a repo set up like this:
/repo/functions/feature.py
/script.sql
/repo/notebooks/task.ipynb
Within feature.py
, I have a function that reads the script.sql
and modifies it based off some input. Importing this function into a notebook within the /functions
directory works just fine.
However, when I have a notebook task.ipynb
in a different directory /notebooks
, the function now gives a "File not found" error. If I move the .sql file to /notebooks
then it works again, but this is far from ideal. I have also considered consolidating all static files into one directory, but this is annoying.
Is there a way to correctly route the file path lookup to always occur within the place it is inputted, regardless of where the function itself is imported and called?