FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Widget persistence API by jdfreder · Pull Request #6789 · ipython/ipython · GitHub

Widget persistence API - #6789

Merged
minrk merged 17 commits into
ipython:masterfrom
jdfreder:persistence2
Dec 9, 2014
Merged

Widget persistence API#6789
minrk merged 17 commits into
ipython:masterfrom
jdfreder:persistence2

Conversation

Copy link
Copy Markdown
Contributor

Instead of persisting widgets ourselves, this PR provides the tools to allow users to persist widget states however they want.

This PR also includes some bugfixes, one of which is the removal of views on cell re-execution!!!
Based on #6664

  • Try it
  • Include examples

@ellisonbg @SylvainCorlay @jasongrout

jdfreder added this to the 3.0 milestone Oct 24, 2014

Copy link
Copy Markdown
Member

Great!

As we think about moving widgets into its own package/library, one of the big questions will be what is the API for other projects (like the notebook) to integrate widgets. I don't know how it affects this PR design but it would be nice if "widgets were just another package" that could be used with the notebook. Because of this I am hesitant to hardwire widget abstractions to the details of the notebook. In some ways, splitting widgets into a separate repo will be the right point to test that these abstractions make sense...

jdfreder force-pushed the persistence2 branch 3 times, most recently from 593a383 to 04c055a Compare October 27, 2014 18:20

Copy link
Copy Markdown
Contributor Author

Looking at this some more, I think I'm going to try to move as much of the persistence as I can into the widget manager (almost all of the code in notebook.js).

Copy link
Copy Markdown
Contributor Author

Hey guys, I've changed this so almost all of the moving parts are isolated to the widget framework, cool! Here's some working code that persists all widgets, visible or not and with live comms, across page refresh.

The widget_manager.get_state method is configurable so you can change the persistence behavior in your persistence implementations:

    WidgetManager.prototype.get_state = function(options) {
        // Get the state of the widget manager.
        //
        // This includes all of the widget models and the cells that they are
        // displayed in.
        //
        // Parameters
        // ----------
        // options: dictionary
        //  Dictionary of options with the following contents:
        //      only_displayed: (optional) boolean=false
        //          Only return models with one or more displayed views.
        //      not_alive: (optional) boolean=false
        //          Include models that have comms with severed connections.

Edit: Removed example.

Copy link
Copy Markdown
Member

Can you rebase this now that #6664 is merged?

jdfreder commented Nov 4, 2014

Copy link
Copy Markdown
Contributor Author

Rebased halfheartedly ... probably very broken at this point. Waiting on Promises PR which should be merge first- and will cause a lot of rebase pain for this PR.

jdfreder commented Nov 4, 2014

Copy link
Copy Markdown
Contributor Author

Waiting on #6818

Copy link
Copy Markdown
Contributor Author

Squashed, rebased, and promisified... Let us see what Travis thinks.

jdfreder force-pushed the persistence2 branch 3 times, most recently from 1af6487 to 0e41b00 Compare November 18, 2014 23:27

Copy link
Copy Markdown
Contributor Author

Needs more promisification...

Copy link
Copy Markdown
Contributor Author

Updated example code:
Edit: removed

Copy link
Copy Markdown
Contributor Author

The tests are passing, but I don't think this is quite ready yet. Still a couple of details to work out about event order.

Copy link
Copy Markdown
Contributor Author

I added a convenience API, so now in addition to custom manager set_state/get_state based loading logic, you can do something as simple as the following to persist widgets to session data:

%%javascript
require(['widgets/js/manager'], function(manager) {
    manager.WidgetManager.set_state_callbacks(function() { // Load
        return JSON.parse(sessionStorage.widgets_state || '{}');
    }, function(state) { // Save
        sessionStorage.widgets_state = JSON.stringify(state);
    });
});

Copy link
Copy Markdown
Contributor Author

Rebased

jdfreder commented Dec 5, 2014

Copy link
Copy Markdown
Contributor Author

Rebased again. Anyone interested in reviewing more? @minrk maybe?

minrk commented Dec 8, 2014

Copy link
Copy Markdown
Member

I've had a look through, and it seems sensible. If @jasongrout and @jdfreder are happy with it, I think it's good to go. Needs rebase first, though.

jdfreder and others added 16 commits December 8, 2014 17:18
This is a combination of 10 commits.
Enable widget instanciation from front-end.

Address @minrk 's review comments.

Make API that allows users to persist widget state easily.

Added support for view persistence

Started adding support for model persistence.

Half way there!

Finished persistence API.

Move persistence code into the widget framework.

Fin.

Bug fixes
make load_state callback support promises.

jdfreder commented Dec 9, 2014

Copy link
Copy Markdown
Contributor Author

@minrk rebased

Comment thread IPython/html/static/components Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I think this components commit is accidental. This commit is older than master.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Sorry about that, seems to happen often when I rebase...

jdfreder commented Dec 9, 2014

Copy link
Copy Markdown
Contributor Author

@minrk submodule commit fixed, I amended my last commit with the correction.

minrk added a commit that referenced this pull request Dec 9, 2014
minrk merged commit 7145927 into ipython:master Dec 9, 2014

jdfreder commented Dec 9, 2014

Copy link
Copy Markdown
Contributor Author

Great, thanks!

jdfreder deleted the persistence2 branch December 9, 2014 19:39
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants


Back | FazBrowse Home | New Git URL