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

Enormous widget state #90

Closed
vidartf opened this issue Apr 7, 2017 · 6 comments
Closed

Enormous widget state #90

vidartf opened this issue Apr 7, 2017 · 6 comments

Comments

@vidartf
Copy link
Member

vidartf commented Apr 7, 2017

Steps to repoduce:

  • Open a new notebook with the following code (extracted from voxel_painter example notebook):
import pythreejs as three

sizex = sizey = 500

surf_geo = three.SurfaceGeometry(
    z = [0]*sizex*sizey,
    width = 2*sizex,
    height = 2*sizey,
    width_segments = 2*sizex//stepx,
    height_segments = 2*sizey//stepy,
)
  • Save notebook with widget state.

Result:
Notebook has more than 500*500 = 250'000 lines, as the z variable is getting one line per entry. This is sufficient to e.g. cause several diff tools to grind to a halt (git gui, github desktop, but not nbdime-web :D).

This might actually be a problem with how Notebook stores lists, but maybe there is a better way to save this?

Related IPyWidgets issue:
The widget state will be kept even after the outputs are cleared. Particularly for the "clear all outputs" action, you would expect all widget state to be cleared as well (I'm not certain how hard it would be to also handle clearing of individual outputs). Now, the only way to clear the widget state is to restart the kernel and click "save notebook with widgets".

@SylvainCorlay
Copy link
Member

Related IPyWidgets issue:
The widget state will be kept even after the outputs are cleared. Particularly for the "clear all outputs" action, you would expect all widget state to be cleared as well (I'm not certain how hard it would be to also handle clearing of individual outputs). Now, the only way to clear the widget state is to restart the kernel and click "save notebook with widgets".

On that regard, this will not be true anymore in Jupyterlab and is an artefact of how we display widgets in the classic notebook, for which widgets are not outputs.

@SylvainCorlay
Copy link
Member

Result:
Notebook has more than 500*500 = 250'000 lines, as the z variable is getting one line per entry. This is sufficient to e.g. cause several diff tools to grind to a halt (git gui, github desktop, but not nbdime-web :D).
This might actually be a problem with how Notebook stores lists, but maybe there is a better way to save this?

Yeah, I guess that lists other than the list of cells should be stored on a single line...

One way to do this without using a companion file would be to have certain fields be serialized in base64.

@vidartf
Copy link
Member Author

vidartf commented Apr 7, 2017

[This] is an artefact of how we display widgets in the classic notebook, for which widgets are not outputs.

Then maybe classic notebook could get a "clear widget state" button? Or is this too specific to this kind of case?

@SylvainCorlay
Copy link
Member

Then maybe classic notebook could get a "clear widget state" button? Or is this too specific to this kind of case?

Totally.

@jasongrout
Copy link
Member

By the way, I just now implemented saving widget binary state as base64 arrays in jupyter-widgets/ipywidgets#1302.

@vidartf
Copy link
Member Author

vidartf commented Dec 14, 2017

With the binary -> base64, and the change in master to use more arrays instead of lists, this is as good as it can get from the pythreejs side. There might be some further tweaks to make, but those should be opened as separate issues/PRs.

@vidartf vidartf closed this as completed Dec 14, 2017
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

3 participants