jupyter_server
jupyter_server copied to clipboard
Notebook Model Path contains UUID ?
Some time JPY_SESSION_NAME was introduce to less kernels know about which file they were attached to,
in particular this was set via
sm.create_session(
path=path, # where this is supposed to be the path of current document.
kernel_name=kernel_name,
kernel_id=kernel_id,
name=name,
type=mtype,
)
Currently this seem to contain UUID, like I get sessions IDs that are like: 'path': 'tests/34361149-e3d8-4dbc-9302-0e86431b3e8c'.
Is that on purpose ?
You can just test that with
import os
os.environ['JPY_SESSION_NAME']
In a python kernel.
Interesting. I'm seeing the same thing, path is a straight UUID value (prefixed with any sub-directories under the root_dir). The server is receiving this value for path in the POST request for the SessionManager to start a kernel. Here's a screenshot from a debug session:

Lab must be setting the filename to a UUID.
Yes, JupyterLab first creates a session with a UUID as the path, then changes the name of the file to the notebook file. This was done as a workaround before we had pending kernels.
FWIW VS Code injects a __vsc_ipynb_file__ variable in the kernel (in globals()) which contains the path to the notebook:
In: __vsc_ipynb_file__
Out: 'd:\\DataScience\\my_notebook.ipynb'
https://github.com/microsoft/vscode-jupyter/issues/8475
Maybe this should be coordinated across all notebook runners (JupyterLab, VS Code, PyCharm, ...)