Programmatically open new notebook

I would love to have my JupyterLab extension detect a specific env variable at start up (like: RESUME_NOTEBOOK) and have it open the notebook at the path specified by the env variable.

Is this achievable? Thank you!

It is doable but you will need 2 extensions.
A labextension (front-end) to run commands to open the notebook (using the core tokens) and a server extension (back-end) to read the env variable, receive requests from the front-end and process them (so to create, read, delete and update files).
JupyterLab handles all of this already (through the filebrowser extension) but it’s limited to where you start it. If you want to open a notebook in this folder then you will be able to reuse JupyterLab’s api (and will only need the front-end extension).

1 Like

Thank you @Remborg I actually managed to do this using IDocumentManager.openOrReveal method to open a Notebook. To detect the env variables I am creating a new Kernel as documented here and running os.envron.get(..) in the Python kernel.

1 Like

Hi @Stefano_Fioravanzo ,

We also have a same requirement where we are already having some notebooks file and want to open those programmatically.
If you don’t mind, can you please share code that worked for you.

Thanks,