Created
August 20, 2018 23:39
-
-
Save kthakore/3aeef003e59894ed389ac0ec97be18f7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const services = require('@jupyterlab/services'); | |
var DEFAULT_OPTIONS = { | |
"kernelName": "python", | |
"path": "/tmp/foo.ipynb", | |
"serverSettings" : services.ServerConnection.makeSettings({ | |
"baseUrl" : process.env.JUPYTER_BASEURL || "http://127.0.0.1:8889", | |
"wsUrl": process.env.JUPYTER_WSURL || "http://127.0.0.1:8889", | |
"token": '', | |
}) | |
}; | |
let options = {...DEFAULT_OPTIONS, path: `/tmp/workspace/${id}`}; | |
let session; | |
let run = new Promise((resolve, reject) => { | |
services.Session.startNew(options).then(async (s) => { | |
session = s; | |
const future = session.kernel.requestExecute({ code: code }) | |
future.onIOPub = function(msg) { | |
console.log(websocket); | |
}; | |
future.onReply = function(reply) { | |
console.log('Got execute reply', reply); | |
}; | |
return future.done | |
}).then(() => { | |
return session.shutdown() | |
}).then(() => { | |
log.info("Session Shutdown") | |
resolve() | |
}) | |
run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment