Skip to content

Commit c4056a5

Browse files
committed
Inject session identifier into environment variable.
There are many use case where users want to know the current notebook name/path. This help by adding a session identifier (to not really say this is the current notebook name), and by default make it the full path to the notebook document that created the session. This will of course not work if the notebook get renamed, but we can tackle this later. See also jupyter/jupyter_client#656, jupyter/notebook#6180. It will need to be ported to jupyter_server as well. This is the mirror commit of jupyter/notebook#6279 on main notebook.
1 parent af1ab9a commit c4056a5

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

jupyter_server/services/sessions/sessionmanager.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,9 @@ async def start_kernel_for_session(self, session_id, path, name, type, kernel_na
138138
# allow contents manager to specify kernels cwd
139139
kernel_path = self.contents_manager.get_kernel_path(path=path)
140140
kernel_id = await self.kernel_manager.start_kernel(
141-
path=kernel_path, kernel_name=kernel_name
141+
path=kernel_path,
142+
kernel_name=kernel_name,
143+
env={"JPY_SESSION_NAME": str(pathlib.Path(path).resolve())},
142144
)
143145
return kernel_id
144146

0 commit comments

Comments
 (0)