Skip to content

Commit

Permalink
Inject session identifier into environment variable.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Carreau committed Jan 25, 2022
1 parent af1ab9a commit c4056a5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion jupyter_server/services/sessions/sessionmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,9 @@ async def start_kernel_for_session(self, session_id, path, name, type, kernel_na
# allow contents manager to specify kernels cwd
kernel_path = self.contents_manager.get_kernel_path(path=path)
kernel_id = await self.kernel_manager.start_kernel(
path=kernel_path, kernel_name=kernel_name
path=kernel_path,
kernel_name=kernel_name,
env={"JPY_SESSION_NAME": str(pathlib.Path(path).resolve())},
)
return kernel_id

Expand Down

0 comments on commit c4056a5

Please sign in to comment.