I am writing a Python package which is designed to be imported into and called from within a jupyter notebook and convert the calling notebook into a specific format. The problem is I can't figure out how to get the path of the calling notebook from within the python script. I know I could just pass the path of the notebook to my python file, but it would be great if that would not be needed and you could just call the myPackage.convertMe() function without any arguments and the calling notebook gets converted.
something like that:
mypackage.py:
def convertMe():
#some magic to convert the calling notebook
my_notebook.ipynb:
import myPackage
myPackage.convertMe()
I already tried inspect.stack()[1].filename but that only outputs the py3compact of the jupyter kernel.
Does anybody have an idea how to do that?