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

Should "Save Widgets" be a checkbox? #1632

Open
dsblank opened this issue Aug 15, 2017 · 21 comments
Open

Should "Save Widgets" be a checkbox? #1632

dsblank opened this issue Aug 15, 2017 · 21 comments
Milestone

Comments

@dsblank
Copy link

dsblank commented Aug 15, 2017

Issue started here: jupyter/notebook#2735

@jasongrout jasongrout added this to the Future milestone Aug 15, 2017
@jasongrout
Copy link
Member

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

@Madhu94
Copy link
Contributor

Madhu94 commented Feb 7, 2018

I'll look into this.

@jasongrout
Copy link
Member

Thanks!

@oscar6echo
Copy link
Contributor

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.

@Madhu94
Copy link
Contributor

Madhu94 commented Feb 19, 2018

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

@oscar6echo
Copy link
Contributor

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 ?

@Madhu94
Copy link
Contributor

Madhu94 commented Feb 19, 2018

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

@oscar6echo
Copy link
Contributor

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.

@oscar6echo
Copy link
Contributor

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

@jasongrout jasongrout modified the milestones: Future, 7.2 Mar 24, 2018
@jasongrout
Copy link
Member

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.

@astrojuanlu
Copy link
Contributor

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.

@dsblank
Copy link
Author

dsblank commented Jul 20, 2018

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?)

@astrojuanlu
Copy link
Contributor

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

@jasongrout
Copy link
Member

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.

@oscar6echo
Copy link
Contributor

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.

@maartenbreddels
Copy link
Member

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.

@vidartf
Copy link
Member

vidartf commented Jul 30, 2018

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

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

@maartenbreddels
Copy link
Member

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

@astrojuanlu
Copy link
Contributor

astrojuanlu commented Oct 1, 2018

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).

@astrojuanlu
Copy link
Contributor

Wondering: does JupyterLab have the same "issue"?

@jasongrout
Copy link
Member

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.

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

No branches or pull requests

7 participants