Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

__session__ picks up new name of a notebook only through specific kernel restarts #1102

Closed
suganya-sk opened this issue Mar 1, 2023 · 5 comments · Fixed by jupyter-server/jupyter_server#1341
Assignees

Comments

@suganya-sk
Copy link

From https://github.com/Quansight/deshaw/issues/167#issuecomment-1420479621, about the __session__ global variable,

That may not yet reflect renames of the file until kernel restart.

On renaming a notebook, the new name is reflected in __session__ when the kernel is started by choosing the same kernel in Kernel -> Change Kernel or Switch Kernel menus. However, the new name is not picked up when kernel is restarted using any of the Kernel -> Restart Kernel ... options.

Is this difference expected?

@Carreau
Copy link
Member

Carreau commented Mar 2, 2023

I'll investigate. It might be an issue on the Jupyter Server side.

@divyansshhh
Copy link

Hi, I'm still able to reproduce this. Any updates here?

@Carreau Carreau self-assigned this Sep 12, 2023
@Carreau
Copy link
Member

Carreau commented Sep 12, 2023

I was not able to narrow down or properly reproduce, I'll retry on more recent versions.

@Carreau
Copy link
Member

Carreau commented Oct 3, 2023

I see where this is coming from. It is fixable but it might take while, time to propagate the API changes while keeping backward compatibility.

One way to force __session__ to update is to change kernel twice. Say from KernelA to KernelB, and then back to A.

So reasons related to efficiency and scheduling in cluster the environment of a Kernel is not recomputed on simple restart.

Carreau added a commit to Carreau/jupyter_client that referenced this issue Oct 23, 2023
This allow to update the running env of kernels.

This will allow resolves some inconsistencies between kernel restart, and actually
stopping and starting a kernel session.

In parsley via a few lines in Jupyter Server in update_session, this
will let us update the `__session__` which is supposed to reflect some
information about the current session, and help correct
ipython/ipykernel#1102 where renaming a notebook is not reflected in the
kernel unless you manually stop/start the session, or restart the
server.
Carreau added a commit to Carreau/jupyter_server that referenced this issue Oct 23, 2023
This rely on jupyter/jupyter_client#987 and fixes ipython/ipykernel#1102
When a user rename the notebook in the UI, it will update the kernel
env, so that the ``__session__`` variable reflect the new name on the
next restart.

It _does_ seem that each rename of a notebook in JupyterLab creates 4
update_session (2 with name, and 2 with path), but that does not seem to
be a problem in this repository.
blink1073 pushed a commit to jupyter/jupyter_client that referenced this issue Oct 23, 2023
This allow to update the running env of kernels.

This will allow resolves some inconsistencies between kernel restart, and actually
stopping and starting a kernel session.

In parsley via a few lines in Jupyter Server in update_session, this
will let us update the `__session__` which is supposed to reflect some
information about the current session, and help correct
ipython/ipykernel#1102 where renaming a notebook is not reflected in the
kernel unless you manually stop/start the session, or restart the
server.
@Carreau
Copy link
Member

Carreau commented Nov 7, 2023

This now should be fixed if you have the latest Jupyter_client (8.6), and Jupyter_server (2.10)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants