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

Widget persistence: only create comm for widgets having valid widget ids #62

Merged
merged 3 commits into from Jul 30, 2015

Conversation

SylvainCorlay
Copy link
Member

This PR has two part:

  • it implements a workaround only based on comms to the absence of comm_info_[request/reply] message. The workaround works as follow: instead of sending a comm_info_request, the front-end opens a comm whose target is a widget that sends back the list of live comms and commits suicide.

This initially required the following PRs related to the comm_info_[request/reply] messages: jupyter/jupyter_client#34, ipython/ipykernel#25, jupyter/notebook#166. The code using this proper version is committed and commented out.

  • then it deals with persistence:
    • comms are only created for valid ids
    • request_state is not called for invalid ids.
    • create_model is decomposed into the creation of the comm and new_model, which does not create a comm when it is not provided with one.

@minrk
Copy link
Contributor

minrk commented Jun 22, 2015

I know the multi-PR nature of changes like this is annoying, but I think it appropriately reflects the significance of such changes, since there are many consumers of these interfaces that aren't us, now.

@SylvainCorlay
Copy link
Member Author

Until last week, widget persistence did for containers like HBox([Button(), Button()]), or for custom models. (cf #49 and #58), hence I am not too concerned about breaking backward compatibility for particular case of the persistence API.

@jdfreder
Copy link
Contributor

The comm:dead event is not triggered anymore when creating a comm-less model. This event is meant to the case where the comm dies (like for a kernel restart).

Is the thinking here that a widget model starts comm-less, until a comm is connected?

@SylvainCorlay
Copy link
Member Author

The comm:dead event is not triggered anymore when creating a comm-less model. This event is meant to the case where the comm dies (like for a kernel restart).

Is the thinking here that a widget model starts comm-less, until a comm is connected?

The idea is to have a version of create_model that takes a model_id but does not create a comm for it. In the persistence, widget models with model ids that are not in the comm list for the comm_list request will not get a comm.

@SylvainCorlay
Copy link
Member Author

To me, this PR is more of a bug fix / cleanup. The current behavior in case of reload, is that all models are created with the assumption that they have a valid comm, which is not true. Then after they are constructed, comm_live is forcibly set to false, and back to true after the state request...

It causes a lot of bugs for things like widgets that create children in their constructors, because thy recreate new widgets, then receive the old children from the backend state request etc...

The comm_list_[request/reply] thing is really required for widgets is really required to correctly implement persistence.

@jdfreder
Copy link
Contributor

I was thinking from an aesthetic stand point. There will need to be a convenient way for someone to programmatically detect if the widget is connected to the back-end, for the purpose of the broken link icon that indicates a severed connection.

@SylvainCorlay
Copy link
Member Author

No worries, this feature will remain.

@SylvainCorlay
Copy link
Member Author

Besides, I think this should be in 4.0.

@jdfreder
Copy link
Contributor

4.0 is okay with me. The other devs will probably have an opinion WRT to the other PRs too.

@jdfreder jdfreder modified the milestones: 4.0, 5.0 Jun 23, 2015
@SylvainCorlay
Copy link
Member Author

I think that Min was in favor of the new message. It is a minor bump in the protocol, and getting a list of open comms from the backend is really needed for anything that would use the comm API to be persistent.

@SylvainCorlay
Copy link
Member Author

Finished with the items listed.

@jdfreder jdfreder modified the milestones: 5.0, 4.0 Jun 24, 2015
@SylvainCorlay SylvainCorlay force-pushed the live_comms branch 3 times, most recently from 8ce63f6 to 07cb46d Compare June 24, 2015 22:10
@SylvainCorlay
Copy link
Member Author

@jdfreder I commited a workaround for the comm_list. I could open a PR with the first two commits, (without the comm_list function) which are very simple to remove some noise.

@SylvainCorlay SylvainCorlay changed the title WIP: changes in persistence Widget persistence: only create comm for widget having valid widget ids Jun 24, 2015
@SylvainCorlay SylvainCorlay changed the title Widget persistence: only create comm for widget having valid widget ids Widget persistence: only create comm for widgets having valid widget ids Jun 24, 2015
@SylvainCorlay SylvainCorlay force-pushed the live_comms branch 2 times, most recently from 0b7202e to 2c45472 Compare June 28, 2015 00:12
@SylvainCorlay SylvainCorlay force-pushed the live_comms branch 6 times, most recently from bb59860 to 67d568f Compare July 15, 2015 18:31
@SylvainCorlay
Copy link
Member Author

@jdfreder @jasongrout I rebased the PR and squashed a few commits.

@SylvainCorlay
Copy link
Member Author

One big issue IMO is that even when the new message gets in, we will need to keep using workarounds to be backward compatible with 4.0...

@minrk
Copy link
Contributor

minrk commented Jul 28, 2015

This doesn't merge anymore. Can you rebase? @jdfreder once it's mergeable, can you have another review pass?

@jdfreder
Copy link
Contributor

Yes, @SylvainCorlay ping me when it's rebased.

@SylvainCorlay
Copy link
Member Author

@jdfreder rebased

jdfreder added a commit that referenced this pull request Jul 30, 2015
Widget persistence: only create comm for widgets having valid widget ids
@jdfreder jdfreder merged commit 33bee75 into jupyter-widgets:master Jul 30, 2015
@jdfreder
Copy link
Contributor

Thanks!

@SylvainCorlay SylvainCorlay deleted the live_comms branch July 30, 2015 16:17
@SylvainCorlay
Copy link
Member Author

@jdfreder you were not sure about the names for new_model / create_model. If you have suggestions, let me know. create_model is the only one we must keep for backward compat.

@jdfreder
Copy link
Contributor

Yeah it still bothers me, but I figured we should get the PR in so the code doesn't go stale.

@github-actions github-actions bot added the resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion. label Feb 28, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 28, 2021
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

Successfully merging this pull request may close these issues.

None yet

3 participants