Start a Jupyter notebook server inside a routine, with access to environment of parent?

I am hoping that it is possible to start a start a notebook server from insider a routine in such a way that has access to the internal namespace of that routine. The reason to want to do this is for code development inside a very large GUI-driven Python program. Trying to run commands in a notebook to duplicate the environment deep inside my code seems hopeless.

Why do this? One way that I do develop code is to use IPython.terminal.embed.InteractiveShellEmbed() to start an IPython session that has access to the local environment where I call it. In that way (for example) I can try out code where I have access to the variables etc. that I find inside a class. It would be way better to do the same thing inside a Jupyter notebook, where I have a log of everything that worked and what it did than IPython.

I tried using notebook.notebookapp.NotebookApp() to start a server process. It works, but does not have any information from the parent. Perhaps there are args to NotebookApp or .initialize() or .start() that would help, but I have not been able to find any documentation on them.

Note that this question was originally raised on StackOverflow where there are a lot more details.

1 Like