feat: include state to reproduce the visual state #207
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
cc @eteq
For any notebook, we'd like to be able to reproduce what was done by including the state of the glue app in the notebook. To get to this, a human-readable text with all parameters that are changed from default would do.
However, this means we have to render a custom text when:
1. The kernel is disconnected
The PR as it is now, would allow for the following:
After we render this:
and then kill the kernel, it would show:
Which can include a custom msg that can 'implement' the reproducibility text.
If the widget state is saved in the notebook, this would also render on page refresh, or when someone else would open the notebook on his/her computer.
2. (?) The widget state is not in the notebook
If the widget state is not included in the notebook, classical notebook will always render like:
Which is due to https://github.com/jupyter-widgets/ipywidgets/blob/90c1c14211a6be685c6077646f40973f96faced1/widgetsnbextension/src/extension.js#L149
The same in JupyterLab:
Which is due to:
https://github.com/jupyter-widgets/ipywidgets/blob/90c1c14211a6be685c6077646f40973f96faced1/packages/jupyterlab-manager/src/renderer.ts#L56
Both is theory could default to do something else (render the HTML instead, like in item 3), but this might be a difficult change (does this break things?), or a difficult to configure setting (in notebook metadata?). Technically not difficult to change though.
3. The widget libraries do not work/or render
When a notebook is opened, but rendering fails due to js libraries not being present, or in the case of GitHub because of security concerns, Jupyter will fall back to rendering lower priority mine types, such as HTML. This means we need to get the mime bundle in the output of the notebook up to date with the state of the glue application/viewer.
One way to do this:
This last step will however redraw the whole application/widget/viewer, and does not look good or lead to a good user experience.
We could possibly see if we can optimize this rendering (e.g. detect if we can skip a redraw), or find other ways of updating the mime bundle.
I hope this gives a bit of an overview of what is possible and what requires changes to the ecosystem.