-1

I have a Jupyter notebook(parent.ipynb) which runs another notebook(child.ipynb) inside it.

Is there a way to get the filename of the parent file from inside the child file? My child file has a logger and therefore can be called by multiple files. It needs to know which file is calling the logger to create log records and therefore I was wondering if there is any magic or any sort of method that can help me with this.

Basically,

A.ipynb

[1] %run B.ipynb

B.ipynb

-- insert code that can print parent filename when called --

halfer
  • 19,824
  • 17
  • 99
  • 186
Aakash Verma
  • 3,705
  • 5
  • 29
  • 66

1 Answers1

-1

add header inside the parent file as follow:

import child
Dejene T.
  • 973
  • 8
  • 14