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

Decouple the notebook from the widget manager. #151

Merged
merged 10 commits into from
Oct 13, 2015

Conversation

jdfreder
Copy link
Contributor

Separate the parts of the widget manager than need comm_manager and notebook instances to work from the base. Allows people to write there own widget managers, without a notebook or comm_manager.

@jdfreder jdfreder added this to the 4.1 milestone Aug 26, 2015
@jdfreder
Copy link
Contributor Author

@rgbkrk is interested in this

@rgbkrk
Copy link
Contributor

rgbkrk commented Aug 26, 2015

Sweet, thanks for the ping. I'll watch this closely, use it in the notebook, and review where I can.

@jdfreder jdfreder changed the title WIP: Decouple the notebook from ipywidgets. Decouple the notebook from the widget manager. Aug 29, 2015
@rgbkrk
Copy link
Contributor

rgbkrk commented Aug 29, 2015

From Jon in chat:

We'll also need to make sure ipywidgets can be npm installed, in a follow on PR.
In case you want to experiment while I'm gone, you'll need to inherit from the manager base to create your own manager then, there are a couple methods that need to be overridden

I'm saying all this in case you want to experiment next week while I'm gone

@jdfreder
Copy link
Contributor Author

@rgbkrk @SylvainCorlay this is ready for review : )

@rgbkrk
Copy link
Contributor

rgbkrk commented Sep 12, 2015

/me drools

}).catch(utils.reject('Could not set widget manager state.', true));
};

WidgetManager.prototype._get_connected_kernel = function() {
ManagerBase.prototype._create_comm = function(comm_target_name, model_id, metadata) {
throw new Error("Manager ._create_comm not implemented");
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm assuming you didn't mean to put a space after Manager and before the . here or below.

@rgbkrk
Copy link
Contributor

rgbkrk commented Sep 12, 2015

Is it too much to ask that since you created new classes and functions that you could write (at the very least) some small mocha tests on the side to run through node?

@jdfreder
Copy link
Contributor Author

@rgbkrk I just tried, and mocha tests in this PR are a no-go because the widgets use AMD. I do not object to node-ifying the widgets in another PR and then adding mocha tests to that.

WidgetManager.prototype.create_model = function (options) {
console.warn('WidgetManager.create_model is deprecated. Use WidgetManager.new_widget');
ManagerBase.prototype.create_model = function (options) {
console.warn('ManagerBase.create_model is deprecated. Use ManagerBase.new_widget');
Copy link
Member

Choose a reason for hiding this comment

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

Could we move this to WidgetManager, so that we don't carry deprecated classes to the cleaner future?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

✔️

@SylvainCorlay
Copy link
Member

A big 👍 to this. @ChakriCherukuri could be interested to look at this as well.

@jankatins
Copy link

I was looking into what needs to be done to build a shiny clone (like a notebook, which is executed in the backend and only the output is sent to the frontend -> static content and widgets; only widgets can communicate with the backend via the widget protocol) and one thing I found that the widgets have / need direct access to the kernel. IMO this would prevent such a usage, as this means that a potential public interface can (via the browser js console) submit python code to execute on the kernel.

Is it planned to also decouple the kernel connection from the widgets in this PR?

@jdfreder
Copy link
Contributor Author

Hi @JanSchulz ,

This PR decouples the notebook, kernel, etc from the WidgetManager. My next step, in another PR, is to do the same for the Widget base class. Once that's done, all that is required to display widgets outside of the notebook is an implementation of the ManagerBase class and a dummy comm.

I did this work a couple of times in the past, never to be merged. You can see the last go, almost a year and a half ago here.

@SylvainCorlay
Copy link
Member

Currently running on this branch and things seem to work.

@jdfreder
Copy link
Contributor Author

Awesome, well it's ready to merge when you are. I'd be happy to continue my decoupling in more PRs, to follow.

@rgbkrk
Copy link
Contributor

rgbkrk commented Oct 12, 2015

Awesome! Once this is shipped if there's more decoupling, I'll try it out in jupyter-sidecar.

/cc @parente

@lbustelo
Copy link

Basic question... If you take the Comm out of the widget manager... what does it do then? From the perspective of jupyter-incubator/declarativewidgets we've identified WidgetManager as a class that is core to interactive widgets. What are the use case that is requiring both Comm and Notebook to be decoupled?

@rgbkrk
Copy link
Contributor

rgbkrk commented Oct 12, 2015

What are the use case that is requiring both Comm and Notebook to be decoupled?

  • Thebe isn't really the notebook and should work with only kernel access
  • Dashboards could work without a notebook setup
  • Dashboards that aren't tied to a live backend
  • Atom packages that would like to feature the widgets as well Hydrogen, Atom-Notebook
  • Electron apps that are not the notebook, e.g. sidecar

@lbustelo
Copy link

Thanks @rgbkrk! I think many of these PRs need to start with some documentation of WHY.

It is hard to keep up and almost feel like unnecessary effort until the dust settles.

@jdfreder
Copy link
Contributor Author

@lbustelo sorry, in the next PR I will try to better explain the "why". In the following PRs I'll embrace duck typing for the comm.

@rgbkrk
Copy link
Contributor

rgbkrk commented Oct 13, 2015

Thank you @lbustelo for asking! I definitely don't want to hide any of this away.

@SylvainCorlay
Copy link
Member

hop!

SylvainCorlay added a commit that referenced this pull request Oct 13, 2015
Decouple the notebook from the widget manager.
@SylvainCorlay SylvainCorlay merged commit 7377c4e into jupyter-widgets:master Oct 13, 2015
@rgbkrk
Copy link
Contributor

rgbkrk commented Oct 13, 2015

🎉

@SylvainCorlay
Copy link
Member

Can't wait to be able to use pythreejs and bqplot in other front-ends like the sidecar.

@github-actions github-actions bot added the resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion. label Feb 28, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 28, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants