Ipywidgets: Should "Save Widgets" be a checkbox?

Created on 15 Aug 2017  路  21Comments  路  Source: jupyter-widgets/ipywidgets

Most helpful comment

But I'm not sure of the use case for not saving? Is there one?

I wonder the same thing. Right now, what I usually do is:

  1. Save a notebook
  2. Share with somebody, or generate some slides, or an HTML
  3. Realize that the widget state was not saved
  4. Rerun and go to 1

All 21 comments

Thanks - this makes a lot of sense if there are the appropriate notebook hooks.

I'll look into this.

Thanks!

As requested by @Madhu94 let here is a summary of my suggestion in #1952:

It think the notebook regular button should perform these operations in sequence:

  • clear all past widget states (to avoid piling them up)
  • save current widget state (if any)
  • save notebook

so that widgets

  • are a natural part of the notebook experience to the regular user.
  • can be saved through nbconvert - important to users running/saving/converting notebooks in batch as part of a publishing pipeline.

Would it be useful to have this information persisted in the user's config files?

I am not sure what you mean exactly by user's config file.
But my initial idea would be to have the info (widget state I suppose you mean) in the notebook itself.
If this is the case well nothing more is required, right ? Or did I miss something ?

Oh sorry, I was referring to the addition of a checkbox to save widget state by default. When the user makes a choice to leave this checked or not, should we save this choice somewhere (like in jupyter_notebook_config.py ? Or the metadata of the notebook might do

Ah ok ! Then I think yes.
Indeed if the jupyter_notebook_config.py should have a variable that determines whether the save widget box is checked upon start. That would be very convenient.

Cf. issue jupyter/nbconvert#751 as several people (incl. me) would like to be able to save widget state from nbconvert.

It looks like there are appropriate hooks in the classic notebook:

https://github.com/jupyter/notebook/blob/2aac713937c0487dd2193c85a69f02e9556421fe/notebook/static/notebook/js/notebook.js#L2729

There is an event that the notebook triggers before saving - perhaps in the widgets menu we have a setting (i.e., menu item with toggle checkmark) that automatically saves the widget state when you save the notebook.

This goes along with #2012.

I arrived here looking for issues and discussion regarding widgets state in notebooks. Has there been a debate to save the widgets state by default? I find the current behavior, plus the lack of support for ipywidgets >= 7 in nbconvert, suboptimal.

I agree that saving widget state by default would make the most sense. Having a checkbox (default checked) would allow those that don't want the state saved the option. (But I'm not sure of the use case for not saving? Is there one? There was a bug previously that state kept accumulating. Is that still a problem?)

But I'm not sure of the use case for not saving? Is there one?

I wonder the same thing. Right now, what I usually do is:

  1. Save a notebook
  2. Share with somebody, or generate some slides, or an HTML
  3. Realize that the widget state was not saved
  4. Rerun and go to 1

We used to save the widget state by default. However, in most of the use cases we saw, widgets were used as transient guis that didn't make sense when the notebook was opened again, so there was little benefit to the constant churn and bloating of notebooks with widget state.

I like the simplicity of a checkbox, but I think I would default to off rather than on, or at least make it a user-defined setting whether it should default to off or on.

As far as I can see, often in my company, ipywidgets are used as (dynamic) illustrations and people expect them to persist just like say matplotlib pictures. For those who specifically want to save light notebooks, they 'clear all outputs/widget states'. For the users I know both of these actions could be merged.

More importantly, It think it is really crucial that people running notebooks programmatically and snapshoting them as html pages (using nbconvert) can save widget states. I don't think this is possible now and it is a serious limitation to that sort of power user.
Currently widget state must be manually first cleared then saved, otherwise it accumulates (bug) and that bloats the notebook/html.

At the tutorials at scipy I also had to explain this, I think it would be more natural for them to be included. We could optimize it a bit, by 'tree shaking', finding widgets that are not linked to any widget that has a view.

I would also find a opt-out option more logical, you expect output all to be included in the notebook, and if it becomes huge/large/slow, you'll need to find ways to circumvent this, i.e. disable it.

We could optimize it a bit, by 'tree shaking'

(Simple) code for this is already in the embed module

Yes, that code comes from ipyvolume, but it is kernel side. For this, I guess we want something similar for the front-end.

Another idea would be to have some sort of warning before closing the tab, saying something like "Hey, are you sure you don't want to save the widgets state? It will be lost if you don't (check here to disable future warnings like this)". This does not require any change in the backend logic but would be a big usability improvement for fools like me (yes, I've been hit by this today again).

Wondering: does JupyterLab have the same "issue"?

JupyterLab has this setting in the settings menu:
Screen Shot 2019-07-10 at 11 40 38 AM

When that is set, saving a notebook saves the widget state. When it is unset, we don't touch the notebook's saved state.

Was this page helpful?
0 / 5 - 0 ratings