-
Notifications
You must be signed in to change notification settings - Fork 48
[Issue: 169] Frontend hardcodes python3 #211
Conversation
res.status(response.statusCode).json(body); | ||
}); | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this is WIP, so I won't have full review comments, but I just want to say that you should adhere to the coding style already in the file:
- Indentation is 4 spaces (not 2).
- Add appropriate spaces around keywords (i.e.
} else {
).
@jameslmartin Focus on trying Toree next since the IRKernel fix might not be released for some time. I know for a fact that Toree works through jupyter-js-services and kernel gateway since it's one of our demos for the kernel gateway project. If you don't see it working here with a simple print, then something else is wrong. Other than code style review like @jhpedemonte gave above, we're holding off on merging this until we see it work with at least one other kernel beyond Python. |
I see you fixed Toree in your last commit. Cool. I think this just needs a rebase on master, a fix of the style @jhpedemonte pointed out, and the inclusion of one really simple Scala notebook for manual test and we can send it in. |
@jameslmartin and @jhpedemonte will pair today to see where this stands and how to get it in for 0.6.0 |
(c) Copyright IBM Corp. 2016
…olves jupyter#169 (c) Copyright IBM Corp. 2016
(c) Copyright IBM Corp. 2016
(c) Copyright IBM Corp. 2016
(c) Copyright IBM Corp. 2016
3fdb583
to
d215e05
Compare
(c) Copyright IBM Corp. 2016
Paired with @jameslmartin to finish this up. Found a couple of things:
|
…ebook frokm nbstore (c) Copyright IBM Corp. 2016
@@ -10,7 +10,7 @@ | |||
var $ = require('jquery'); | |||
var Widgets = require('jupyter-js-widgets'); | |||
|
|||
var WidgetManager = function(kernel, msgHandler) { | |||
var WidgetManager = function(kernel, kernelname, msgHandler) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IKernel
(type of kernel
) has a name
property, but it always seems to come back as empty string in my testing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, so kernel.name
is an empty string because we pass an empty string now when calling startNewKernel
. Instead, I think we should do this:
diff --git a/client/js/dashboard.js b/client/js/dashboard.js
index fec0656..c88d37e 100644
--- a/client/js/dashboard.js
+++ b/client/js/dashboard.js
@@ -50,7 +50,7 @@ if (Element && !Element.prototype.matches) {
var renderMime = _createRenderMime();
// start a kernel
- Kernel.start().then(function(kernel) {
+ Kernel.start(Config.kernelname).then(function(kernel) {
// do some additional shimming
_setKernelShims(kernel);
@@ -58,7 +58,7 @@ if (Element && !Element.prototype.matches) {
_registerKernelErrorHandler(kernel);
// initialize an ipywidgets manager
- var widgetManager = new WidgetManager(kernel, Config.kernelname, _consumeMessage);
+ var widgetManager = new WidgetManager(kernel, _consumeMessage);
// initialize Declarative Widgets library
var widgetsReady = _initDeclWidgets();
diff --git a/client/js/kernel.js b/client/js/kernel.js
index 4444210..a15135a 100644
--- a/client/js/kernel.js
+++ b/client/js/kernel.js
@@ -18,14 +18,14 @@ var Services = require('jupyter-js-services');
var _kernel;
- function _startKernel() {
+ function _startKernel(kernelname) {
var loc = window.location;
var kernelUrl = loc.protocol + '//' + loc.host;
var clientId = _uuid();
var kernelOptions = {
baseUrl: kernelUrl,
wsUrl: kernelUrl.replace(/^http/, 'ws'),
- name: '', // Set by API when making POST request to kernel gateway
+ name: kernelname,
clientId: clientId,
ajaxSettings: {
requestHeaders: {
diff --git a/client/js/widget-manager.js b/client/js/widget-manager.js
index 278b2e8..d3a717c 100644
--- a/client/js/widget-manager.js
+++ b/client/js/widget-manager.js
@@ -10,7 +10,7 @@
var $ = require('jquery');
var Widgets = require('jupyter-js-widgets');
- var WidgetManager = function(kernel, kernelname, msgHandler) {
+ var WidgetManager = function(kernel, msgHandler) {
// Call the base class.
Widgets.ManagerBase.call(this);
@@ -26,7 +26,7 @@ var Widgets = require('jupyter-js-widgets');
// Validate the version requested by the backend -- required for ipywidgets
// If kernel name is not defined, default to python3
- kernelname = kernelname.toLowerCase();
+ var kernelname = kernel.name.toLowerCase();
if (!kernelname || kernelname === 'python3' || kernelname === 'python2') {
var validate = (function validate() {
this.validateVersion().then(function(valid) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if this is what we want to do here. The original bug was that the front end was hardcoding 'python3' into that field, kernel.name
. @parente and I discussed that the back end should determine what type of kernel should be started, rather having the front end pass along the name.
However, we do need the kernel name for the widget manager. Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See below.
Notebooks (i.e. test_widget_overlap) which specify
And I see this from the kernel gateway:
Running these notebooks in Notebook works just fine. Editing notebook to use |
Help me disentangle.
The kernel gateway dev Docker image needs to install ipywidgets against the python2 environment.
Was this only for python2? If so, see above. If it's for Toree too, are the necessary components for decl widgets installed in the kernel gateway container as well?
The frontend will never know the language of the dashboard unless its encoded in the HTML returned by the server. Even then, if that language is passed back to the server, it can't be trusted since the client can be manipulated. Why exactly does the widget manager need to know the language?
Kernel gateway is using the restart handler from notebook as-is. So doubtful. This is a separate issue about OOM handling, so let's put it aside for now. |
// Validate the version requested by the backend -- required for ipywidgets | ||
// If kernel name is not defined, default to python3 | ||
kernelname = kernelname.toLowerCase(); | ||
if (!kernelname || kernelname === 'python3' || kernelname === 'python2') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll also have to include just "python" here, but I really suspect the Python check won't be required once the other issues are resolved (e.g., properly installing the decl widgets scala jar, installing ipywidgets against python2 conda env) .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why exactly does the widget manager need to know the language?
We need it here in this check to run the validation code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. I still think once Scala is setup properly, that special casing for Python will not be needed. I'll get with you and or @jhpedemonte today.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed with @jhpedemonte . For now, we're not going to bother setting up decl widgets for scala since the example is only hello world. Adding whatever config is necessary for a scala decl widgets example to work can come as part of #203.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jhpedemonte also clarified that the validation check does not actually inhibit the Toree kernel from working. It's just an ugly error. We agreed that switching it to a warning that explicitly says ala "Compatible version of ipywidgets is not available" is cleaner than hardcoding python checks and still makes sense with other kernels (yes, ipywidgets is not available for R, Toree, etc.)
One reason we need the kernel name on the client side is because it does the call to |
I'm fine including the kernel name in the template like you're doing as long as we put as many guards as we can in place to make sure that the kernel name determined on the server-side is the only one that's trusted and sent to the kernel gateway. If there's an issue or question to open about how the name is used in jupyter-js-services, please go ahead and report it. |
Superseded by #236 |
This resolves the language of the kernel before sending the POST request to the kernel gateway (#169) . Though the request body is successfully set to the correct language, no activity is observed over the WebSocket channels.