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

JupyterLab manager: widget model not found #2748

Closed
jtpio opened this issue Jan 23, 2020 · 8 comments
Closed

JupyterLab manager: widget model not found #2748

jtpio opened this issue Jan 23, 2020 · 8 comments
Labels
resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion.
Milestone

Comments

@jtpio
Copy link
Member

jtpio commented Jan 23, 2020

Running from the master branch and following these steps:

  • Turn on: "Save Widget State Automatically"
  • Close the notebook
  • Shut down the kernel
  • Refresh the page
  • Open the same notebook
  • Execute the cells

It looks like the widget manager is unable to recreate the widgets after re-executing the cells:

jlab-manager-master-save-state

@jtpio
Copy link
Member Author

jtpio commented Jan 23, 2020

Actually it looks like this happens when the first notebook is opened after a page reload, regardless of whether the widget state is saved or not:

jlab-manager-master-first-notebook

@jtpio
Copy link
Member Author

jtpio commented Jan 23, 2020

Digging into that a little bit: it looks like _handleCommOpen is not reached on subsequent widget creation:

// _handleCommOpen is an attribute, not a method, so `this` is captured in a
// single object that can be registered and removed
protected _handleCommOpen = async (
comm: Kernel.IComm,
msg: KernelMessage.ICommOpenMsg
): Promise<void> => {
const oldComm = new shims.services.Comm(comm);
await this.handle_comm_open(oldComm, msg);
};

Which should be where models are created and registered:

@jtpio
Copy link
Member Author

jtpio commented Jan 24, 2020

Stepping into the code a bit more: it looks like several connections to the kernel are established from the document context when the notebook is open for the first time and the kernel is not running yet.

However at some point, this.handleComms ends up being false here:

https://github.com/jupyterlab/jupyterlab/blob/75422e60eb4ae0af5036c4b7bc31addf9cdfc9ef/packages/services/src/kernel/default.ts#L830

At the time when the first kernelChanged signal is emitted here:

this._handleKernelChanged(args);

Which would explain why the comm target is not registered.

@jasongrout
Copy link
Member

For context:

  1. The first time a kernel is started, the help menu starts up a kernel connection to get the help links from the kernel info, as well as the actual document. So there should be two kernel connections, and then the help menu connection is disposed after the info comes in.
  2. In general, only one connection should be able to handle comms. When creating a new connection, it checks to see if any other connection handles comms, and if another connection handles comms, the default is to not handle comms.

So perhaps the help menu is somehow connecting first, before the document? I haven't seen that, and thought it would not happen.

Regardless, it looks like there is no way when creating a session connection to say that the kernel connection should not handle comms. I think the session connection should have a new initialization argument for the kernel connection options, so that the help menu can specify that its kernel connection does not handle comms ever.

@jasongrout
Copy link
Member

@jtpio - JupyterLab 2.0b3, released today, has a jupyterlab/jupyterlab#7820, which should solve the issue I mention above, if that is the problem that you are seeing. Can you check with JLab 2.0b3?

@jasongrout jasongrout added this to the 8.0 milestone Jan 25, 2020
@jtpio
Copy link
Member Author

jtpio commented Jan 25, 2020

Thanks @jasongrout, just tried with the latest alpha and it looks like it fixes it!

@jtpio
Copy link
Member Author

jtpio commented Jan 25, 2020

  1. In general, only one connection should be able to handle comms. When creating a new connection, it checks to see if any other connection handles comms, and if another connection handles comms, the default is to not handle comms.

Right, this seems to be where this check is happening:

https://github.com/jupyterlab/jupyterlab/blob/3cb64ca6885358e7f9623f518518bb3f9de017bc/packages/services/src/kernel/manager.ts#L113-L122

@jtpio
Copy link
Member Author

jtpio commented Jan 25, 2020

Closing as fixed in JupyterLab 2.0b3 by jupyterlab/jupyterlab#7820.

@jtpio jtpio closed this as completed Jan 25, 2020
@lock lock bot added the resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion. label May 20, 2020
@lock lock bot locked as resolved and limited conversation to collaborators May 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion.
Projects
None yet
Development

No branches or pull requests

2 participants