Skip to content
This repository has been archived by the owner on Sep 1, 2022. It is now read-only.

[WIP] Changes necessary to work standalone similar to ipywidgets examples #157

Closed
wants to merge 4 commits into from

Conversation

lbustelo
Copy link
Collaborator

This PR is just intended as an experiment of what it would take for declarativewidgets to operate in a standalone jupyter-js-services.

I'm following https://github.com/ipython/ipywidgets/tree/9602b80f627656171cbda55ddb92481146325920/examples/development/web3 as a template.

@lbustelo lbustelo force-pushed the StandaloneExperiment branch from 12b4d1c to d227b4a Compare December 16, 2015 19:00
@parente
Copy link
Member

parente commented Dec 16, 2015

We should also compare notes with jupyter/dashboards#127 which is out of date but still has the bulk of the code for using jupyter-js-services instead of Thebe. Also, https://github.com/jupyter-incubator/dashboards_nodejs_app which will be the default ref impl for "give me this notebook as a securable app".

@lbustelo
Copy link
Collaborator Author

A couple of the challenges in this work:

  1. Converting our project into an npm module. Easily started with an index.js but the challenge is what to export. For now I'm just exporting the init function.
  2. The extension js code needs to be altered to support loading as npm package and also on the browser. The demo is using browserify to build the js code.
  3. Where is IPython global? Not that it has to be named that, but were do we find the equivalent dependencies.
  4. WidgetManager vs ManagerBase
  5. bower_components vs urth_components. Had to temporary create a sym link to move along
  6. A require shim is needed to define declare and adjust module loading paths as necessary.

@lbustelo lbustelo force-pushed the StandaloneExperiment branch from 7701390 to ef4a829 Compare December 16, 2015 23:56
@lbustelo
Copy link
Collaborator Author

So basically was able to get through the bootstrap stage of setting up the page with declarativewidgets support. Had to make some changes to prevent undefined access and shim several things on the IPython global.

This demo shows the following:

  1. Bootstrapping of the APP working
  2. A template on the DOM using urth-core-bind directly on the HTML. No need for magic (a la %%HTML).
  3. Code sent to the kernel to set a variable on the channel
  4. The template responding to that variable change and rendering the message.
    standalone_declwid

@lbustelo lbustelo force-pushed the StandaloneExperiment branch from df1acd7 to b6fac88 Compare December 18, 2015 20:40
@lbustelo
Copy link
Collaborator Author

Latest commit modifies the example to use urth-core-function' as well as shimming the 'shell_reply.Kernel event.

standalone_declwid2

@parente
Copy link
Member

parente commented Dec 18, 2015

/cc @dalogsdon @jhpedemonte since you're paving the way for everything that needs to go into jupyter/dashboards_server#2

@@ -35,7 +35,7 @@
"outputs": [],
"source": [
"// modify to IP and Port of this notebook server\n",
"%addjar http://192.168.99.100:8888/nbextensions/urth_widgets/urth-widgets.jar"
"%addjar http://192.168.99.100:8888/nbexten tsions/urth_widgets/urth-widgets.jar"
Copy link
Contributor

Choose a reason for hiding this comment

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

que?

@jhpedemonte
Copy link
Contributor

jupyter-widgets/ipywidgets#383 made a change to WidgetModel which breaks DeclWidgetModel. Specifically, it made _deserialize_state() a "class" level function which is not carried over into DeclWidgetModel when that extends WidgetModel.

I thought of adding generic code such as this:

for (var key in Widgets.WidgetModel) {
    if (Widgets.WidgetModel.hasOwnProperty(key))
        DeclWidgetModel[key] = Widgets.WidgetModel[key]
}

Unfortunately, in addition to _deserialize_state, this would also add extend and __super__ (Backbone related?).

We could just directly map _deserialize_state, but that's fragile. Another option is to make use of the WidgetModel.extend in order to create DeclWidgetModel -- not sure if that will bring over "class" method.

Also, I don't like that we need to bring over a "private" (starts with underscore) method in order to extend WidgetModel. I'll open an issue with ipywidgets.

@jhpedemonte
Copy link
Contributor

Another option is to make use of the WidgetModel.extend in order to create DeclWidgetModel

This works.

@jhpedemonte
Copy link
Contributor

Another issue: new_widget() now expects a serialized_state as 2nd argument. I'm currently failing on JupyterWidgetBehavior._doCreateModel(), which only passes in an options arg. @lbustelo, any ideas on how best to fix that? I'll keep investigating.

@lbustelo
Copy link
Collaborator Author

I'm closing this PR since @jhpedemonte has already made the necessary changes in #251

@lbustelo lbustelo closed this Mar 16, 2016
@minrk minrk deleted the StandaloneExperiment branch February 14, 2017 15:38
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants