本文整理汇总了TypeScript中jupyter-js-services.startNewSession函数的典型用法代码示例。如果您正苦于以下问题:TypeScript startNewSession函数的具体用法?TypeScript startNewSession怎么用?TypeScript startNewSession使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了startNewSession函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: main
function main(): void {
startNewSession({
path: 'fake_path',
}).then(session => {
startApp(session);
});
}
示例2: main
function main() {
// Start a new session.
let options = {
baseUrl: BASE_URL,
wsUrl: WS_URL,
kernelName: 'python',
path: 'foo.ipynb'
};
startNewSession(options).then(session => {
// Rename the session.
session.rename('bar.ipynb').then(() => {
console.log('Session renamed to', session.path);
// Execute and handle replies on the kernel.
let future = session.kernel.execute({ code: 'a = 1' });
future.onReply = (reply) => {
console.log('Got execute reply');
};
future.onDone = () => {
console.log('Future is fulfilled');
// Shut down the session.
session.shutdown().then(() => {
console.log('Session shut down');
alert('Test Complete! See the console output for details');
});
};
});
});
}
示例3: main
function main() {
// Start a new session.
let options = {
baseUrl: BASE_URL,
wsUrl: WS_URL,
kernelName: 'python',
notebookPath: 'foo.ipynb'
};
startNewSession(options).then(session => {
// Rename the notebook.
session.renameNotebook('bar.ipynb').then(() => {
console.log('Notebook renamed to', session.notebookPath);
// Execute and handle replies on the kernel.
var future = session.kernel.execute({ code: 'a = 1' });
future.onReply = (reply) => {
console.log('Got execute reply');
};
future.onDone = () => {
console.log('Future is fulfilled');
// Shut down the session.
session.shutdown().then(() => {
console.log('Session shut down');
});
};
});
});
}
示例4: getKernelSpecs
getKernelSpecs({}).then(specs => {
kernelspecs = specs;
// start session
startNewSession({
notebookPath: NOTEBOOK,
kernelName: findKernel(nbModel, specs),
baseUrl: SERVER_URL
}).then(session => {
nbModel.session = session;
});
});
示例5: getKernelSpecs
getKernelSpecs({}).then(specs => {
kernelspecs = specs;
let kernelName = specs.default;
let language = specs.default;
console.log('specs', specs);
return startNewSession({
notebookPath: 'fake_path',
kernelName: findKernel(kernelName, language, specs),
baseUrl: SERVER_URL
});
}).then(session => consoleModel.session = session);
示例6: NotebookModel
contents.get(NOTEBOOK, {}).then(data => {
let nbModel = new NotebookModel();
populateNotebookModel(nbModel, data.content as NotebookContent);
let nbWidget = new NotebookWidget(nbModel);
keymap.add(bindings(nbModel));
nbWidget.attach(document.body);
// start session
startNewSession({
notebookPath: NOTEBOOK,
kernelName: data.content.metadata.kernelspec.name,
baseUrl: SERVER_URL
}).then(session => {
nbModel.session = session;
let content = getNotebookContent(nbModel);
contents.save(NOTEBOOK, {
type: 'notebook',
content
});
});
});
示例7: main
function main(): void {
let path = 'dummy_path';
let query: { [key: string]: string } = Object.create(null);
window.location.search.substr(1).split('&').forEach(item => {
let pair = item.split('=');
if (pair[0]) {
query[pair[0]] = pair[1];
}
});
if (!query['path']) {
startNewSession({ path }).then(session => { startApp(session); });
return;
}
findSessionByPath(query['path'])
.then(model => { return connectToSession(model.id); })
.then(session => { startApp(session); })
.catch(error => {
console.warn(`path="${query['path']}"`, error);
startNewSession({ path }).then(session => { startApp(session); });
});
}
示例8: startNewSession
.catch(error => {
console.warn(`path="${query['path']}"`, error);
startNewSession({ path }).then(session => { startApp(session); });
});