Skip to content
This repository was archived by the owner on Aug 30, 2022. It is now read-only.

WIP: Migrate to jupyter-js-services #127

Conversation

jhpedemonte
Copy link
Collaborator

Based on 4.x branch.

This works for simple notebooks which don't contain widgets.

Ref #105

* Adopt jupyter project versioning scheme
* Bump to 0.2.0.dev
* Introduce make build target for dev image including bower
* Update dev automation for 4.x config, path changes

(c) Copyright IBM Corp. 2015
(c) Copyright IBM Corp. 2015
* Remove cell selection border color
* Handle new image double click overflow behavior (css not js)

(c) Copyright IBM Corp. 2015
* Remove test_converter_layout, precursor to local deploy

(c) Copyright IBM Corp. 2015
* No host npm
* make build before test
* No need to prefetch docker image

(c) Copyright IBM Corp. 2015
@jhpedemonte jhpedemonte changed the title Migrate to jupyter-js-services WIP: Migrate to jupyter-js-services Nov 11, 2015
// IPython.notebook.kernel.comm_manager.register_target('matplotlib', mpl.mpl_figure_comm)

var options = {
baseUrl: 'http://192.168.99.100:9500',
Copy link
Member

Choose a reason for hiding this comment

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

Reminder for later: read Urth options instead of hardcoding. Also, need to mimic spawn call for container that thebe does ahead of requesting a kernel. (jupyter-js-services assumes the kernel provider container is pre-running, i.e., the notebook server.)

@jhpedemonte
Copy link
Collaborator Author

OK, was finally able to test against both old and new tmpnb impls.

Note the added TODO? block. I did not add support (yet) for checking for existing kernels. Not sure if we want to go down that route or simply always kill the kernel when leaving page (even on reload). @parente, what do you think?

@parente
Copy link
Member

parente commented Nov 12, 2015

I worry that killing when leaving the page is too hard to get right. Can you ensure an XHR is sent and processed with confidence on page unload? The state of XHR available at that point is always questionable in my experience.

Thebe also has some fancy logic for writing a cookie to reuse a spawned container if it still exists, to avoid eating up the pool of containers available for other users. I'm open to ideas different from the the Thebe approach or to just mimicking what Thebe does.

But we need to do something for lifecycle management for sure.

@jhpedemonte
Copy link
Collaborator Author

While we can do page unload actions, not sure about XHR. That might be too much to do at that point, but we could try. But this won't take care of issues where page/browser crashes or immediately quits/closes and doesn't allow unload actions.

Yes, the Thebe cookie logic is what I wrote in the TODO? block in the code.


Here's my proposal:

  1. Implement something similar to Thebe's cookie logic. The client code will check to see if last used kernel exists and if so, reuse it.
  2. Have a server process which periodically looks for "stale" kernels (those whose websockets connections are no longer connected to a browser) and kill those.

I think that combination would work well for (1) cases where user refreshes page (kernel is reused); and (2) user leaves page for extended period of time (kernel is killed; new one started next time user returns).

@jhpedemonte
Copy link
Collaborator Author

@parente: Regarding previous comment, we implemented proposal item 1 (storing container URL if one is created and re-using when reloading page). But we're wondering about how this should work with different notebooks/dashboards.

Let's say we have 2 different dashboards, both using tmpnb.org. We start first dashboard, notices there isn't a stored container URL so it spawns a new container, before starting a new kernel (the container URL is stored).

Later, we start the 2nd dashboard. It finds a stored container URL and therefore uses that one, so it does not spawn before creating a new kernel.

Is this OK, to have 2 different dashboards using same container (but different kernels)?

Thebe recently added a check to see if the set URL is same as stored URL. This won't really work with tmpnb.org, since it redirects to a different subdomain (i.e. https://tmp35.tmpnb.org/user/...) -- seems like that check will always fail and so it will always call spawn.

@parente
Copy link
Member

parente commented Nov 12, 2015

Is this OK, to have 2 different dashboards using same container (but different kernels)?

For now, yes, since we're just trying to implement a lighter-weight Thebe, compatible with tmpnb.

But down the line, each dashboard might have different requirements on the container environment (e..g, libs are available, max memory is allocated, ...) That's where the proposal like jupyter/enhancement-proposals#5 come into play for standardizing an API for requesting kernel environments that a variety of providers can implement.

jhpedemonte and others added 3 commits November 17, 2015 16:30
This works with simple notebooks which don't contain widgets.
Add tmpnb support. Tested against new and old tmpnb.
Store container URL to reuse in future.

:cow:

(c) Copyright IBM Corp. 2015
When deploying a dashboard, use the Notebook REST API to create a new Notebook Session. This allows the dashboard kernel to show in the list of currently running notebooks.

(ref jupyter#117)

:chicken:

(c) Copyright IBM Corp. 2015
If in tmpnb mode, create a new kernel rather than using session API.

ref jupyter#117

(c) Copyright IBM Corp. 2015
parente and others added 7 commits December 30, 2015 17:16
Extract bundlers into their own repos
* Adopt jupyter project versioning scheme
* Bump to 0.2.0.dev
* Introduce make build target for dev image including bower
* Update dev automation for 4.x config, path changes

(c) Copyright IBM Corp. 2015
This works with simple notebooks which don't contain widgets.
Add tmpnb support. Tested against new and old tmpnb.
Store container URL to reuse in future.

:cow:

(c) Copyright IBM Corp. 2015
(c) Copyright IBM Corp. 2015
🐷

(c) Copyright IBM Corp. 2015
…emonte/dashboards into migrate-to-jupyter-js-services-105
@parente
Copy link
Member

parente commented Feb 7, 2016

I think we can safely close this. jupyter-incubator/dashboards_nodejs_app has a working implementation tracking bleeding edge jupyter-js-services, jupyter-js-widgets, and so on ...

@parente parente closed this Feb 7, 2016
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