Open galou opened 8 years ago
Hi @galou. This is peculiar indeed. I would take a look at this line: https://github.com/jupyter/atom-notebook/blob/master/lib/notebook-editor.js#L261. In Atom, you can open the dev tools and set a breakpoint at this point in the execution (when opening a notebook file) and inspect the value of spec
and kernelSpecs.kernelspecs
to try to understand what it's spawning freecad kernel vs. python.
I tried to modify notebook-editor.js
without success. When I load the module as development module I receive the error Cannot find module 'pathwatcher'
. What I did was
cd $rep_path
git clone https://github.com/jupyter/atom-notebook.git jupyter-notebook
cd ~/.atom/dev/packages
ln -s $rep_path/jupyter-notebook
atom -d
So far, my modifications:
diff --git a/lib/notebook-editor.js b/lib/notebook-editor.js
index d3bfe38..d576e45 100644
--- a/lib/notebook-editor.js
+++ b/lib/notebook-editor.js
@@ -244,6 +244,7 @@ export default class NotebookEditor {
}
launchKernelGateway() {
+ let name = this.state.getIn(['metadata', 'kernelspec', 'name']);
let language = this.state.getIn(['metadata', 'kernelspec', 'language']);
portfinder.basePort = 8888;
portfinder.getPort({host: 'localhost'}, (err, port) => {
@@ -258,17 +259,34 @@ export default class NotebookEditor {
console.log('kernelGateway.stderr ' + data);
if (data.toString().includes('The Jupyter Kernel Gateway is running at')) {
getKernelSpecs({baseUrl: `http://localhost:${port}`}).then((kernelSpecs) => {
- let spec = Object.keys(kernelSpecs.kernelspecs).find(kernel => kernelSpecs.kernelspecs[kernel].spec.language === language);
- console.log('Kernel: ', spec);
- if (spec) {
+ let kernel_name = Object.keys(kernelSpecs.kernelspecs).find(kernel => kernelSpecs.kernelspecs[kernel].name === name);
+ let spec;
+ if (kernel_name) {
+ spec = kernelSpecs.kernelspecs[kernel_name].spec;
+ }
+ console.log('Kernel (found by name): ', kernel_name);
+ if (spec && spec.language === language) {
startNewKernel({
baseUrl: `http://localhost:${port}`,
wsUrl: `ws://localhost:${port}`,
- name: spec
+ name: kernel_name
}).then((kernel) => {
this.session = kernel;
});
}
+ else {
+ let spec = Object.keys(kernelSpecs.kernelspecs).find(kernel => kernelSpecs.kernelspecs[kernel].spec.language === language);
+ console.log('Kernel (found by language): ', spec);
+ if (spec) {
+ startNewKernel({
+ baseUrl: `http://localhost:${port}`,
+ wsUrl: `ws://localhost:${port}`,
+ name: spec
+ }).then((kernel) => {
+ this.session = kernel;
+ });
+ }
+ }
});
}
});
This is my first experience with Javascript and plugin development with Atom. I'm stuck right now. I tried to first load a kernel by name (while checking the language) and then, if unsuccessful, by language.
Could someone help me further with this improvement? Thanks!
@galou Thanks for taking a stab at this.
First, you will want to follow the dev install instructions (that's why you are seeing Cannot find module 'pathwatcher'
).
After that, you should be able to test you changes within Atom (be sure to reload Atom). You can always switch back to Atom's installed version of atom-notebook by running apm unlink
in your atom-notebook directory.
I have a problem opening an .ipynb file.
In the ipynb file:
"jupyter kernelspec list"
gives:When I open the ipynb file, a FreeCAD window appears. This is the beginning of the log
In the definition of freecad_kernel (
kernel.json
), I have"language": "python"
.The notebook was saved within the web browser launched from
jupyter-notebook
.I would love to see atom-notebook running. It looks great and I don't like editing in the browser. Thanks for providing it! Thank you helping me solving this issue!