Skip to content

Instantly share code, notes, and snippets.

@kthakore
Created August 20, 2018 23:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kthakore/3aeef003e59894ed389ac0ec97be18f7 to your computer and use it in GitHub Desktop.
Save kthakore/3aeef003e59894ed389ac0ec97be18f7 to your computer and use it in GitHub Desktop.
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