Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework kernel and session architecture #7252

Merged
merged 100 commits into from Dec 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
374ecb1
Simplify async logic by using an async anonymous function.
jasongrout Sep 19, 2019
a894cb1
wip
jasongrout Sep 20, 2019
1faae20
Update kernel status to have a connection status and a kernel status.
jasongrout Sep 21, 2019
94ad719
Fix many test failures.
jasongrout Sep 21, 2019
597f973
Updated session to proxy the connection status from the kernel.
jasongrout Sep 23, 2019
974ef17
Delete unnecessary awaits for kernel info replies.
jasongrout Sep 24, 2019
924f4fe
Rework session and clientsession status to just point to the kernel s…
jasongrout Sep 24, 2019
4d9d022
Document an overview of the client session / session / kernel archite…
jasongrout Oct 1, 2019
74071d0
Refactor validation functions
jasongrout Oct 3, 2019
72ea9e9
Move kernel spec functionality to its own module, with its own manage…
jasongrout Oct 3, 2019
9efd678
Factor out common things from the managers into a base manager.
jasongrout Oct 3, 2019
a287b4f
Change session kernel changed signal to be a real IChangedArgs signal.
jasongrout Oct 3, 2019
8c1b436
Use kernel status directly instead of session status.
jasongrout Oct 3, 2019
9746a65
Move kernel rest api communication to new restapi module and caching …
jasongrout Oct 4, 2019
cd5d04a
WIP update session to mirror new kernel refactoring.
jasongrout Oct 5, 2019
ae82116
WIP update for session manager
jasongrout Oct 8, 2019
1b3a37b
Refactor connection construction options and various places models ar…
jasongrout Oct 9, 2019
8cc4100
WIP
jasongrout Nov 15, 2019
03572e3
Fix remaining compile errors in services package
jasongrout Nov 15, 2019
7482b34
Update services to use new TS 3.7 null coalescing and optional chaini…
jasongrout Nov 15, 2019
a3bae85
Use ts 3.7 assertion functions to improve typing.
jasongrout Nov 16, 2019
3a5ae0b
Update core plugins for the changes in services and ClientSession.
jasongrout Nov 20, 2019
96f89b2
Clean up a few more changes we’ve made.
jasongrout Nov 21, 2019
483c056
More correctly use the status in change signals in clientsession.
jasongrout Nov 22, 2019
7410373
WIP clean up tests and kernel starting signatures
jasongrout Nov 24, 2019
1c04505
Reorganize kernelspec and kernel modules to use modules instead of na…
jasongrout Nov 25, 2019
79c84cb
Update services tests and fix relevant bugs.
jasongrout Nov 26, 2019
0e435b2
Export kernel spec rest api
jasongrout Dec 5, 2019
b447b80
wip
jasongrout Dec 10, 2019
5293cd3
wip
jasongrout Dec 10, 2019
50701f7
Rename clientsession files to sessioncontext
jasongrout Dec 10, 2019
cc192f0
Clean up documentation and api for session context
jasongrout Dec 10, 2019
6d7e69c
Clean up kernel api
jasongrout Dec 11, 2019
d8724f5
Change status bar code to indicate kernel sessions, not just kernels
jasongrout Dec 12, 2019
21e1b88
Update completers to handle session changes
jasongrout Dec 12, 2019
77b0890
More API and docs cleanup.
jasongrout Dec 12, 2019
fae3c37
Fix lots of tests
jasongrout Dec 12, 2019
c5dcf16
Trigger ‘restarting’ status ourselves when we initiate the kernel res…
jasongrout Dec 12, 2019
f071fc3
Fix more tests
jasongrout Dec 12, 2019
deed221
Rewrite some of the sessionContext logic as async/await and fix tests.
jasongrout Dec 12, 2019
43718a3
Work through tricky logic around disposing dead kernel connections.
jasongrout Dec 13, 2019
da2fcb0
Fix almost all of the services tests.
jasongrout Dec 13, 2019
be9ea01
Fix session context tests
jasongrout Dec 13, 2019
b9e7aff
Fix the kernel toolbar indicator to show the kernel connection status…
jasongrout Dec 13, 2019
5075531
Fix rendermime tests
jasongrout Dec 13, 2019
39b4471
Add more testing options for comprehensive running tests
jasongrout Dec 13, 2019
00d756a
Add initialize and ready/isReady methods to session context.
jasongrout Dec 13, 2019
516f741
overhaul the test createFileContext utility functions
jasongrout Dec 13, 2019
3ad329e
Fix more tests.
jasongrout Dec 14, 2019
f93c404
Fix remaining failing tests.
jasongrout Dec 14, 2019
b8de3a6
Merge branch 'master' into sessionpersistence
jasongrout Dec 14, 2019
55138af
Fix compile errors
jasongrout Dec 14, 2019
338317f
Remove the sessionContext.kernel convenient shortcut.
jasongrout Dec 14, 2019
55317db
Clean up comments and formatting.
jasongrout Dec 14, 2019
19c44df
Make status bar explicitly and accurately have a tooltop of “kernel s…
jasongrout Dec 14, 2019
8722b89
Fix linting errors
jasongrout Dec 14, 2019
6de2dfc
Fix tests
jasongrout Dec 14, 2019
985dcf6
Fix tests
jasongrout Dec 15, 2019
624d49b
Fix building examples
jasongrout Dec 15, 2019
1943ff5
Take care of some TODOs that are no longer applicable.
jasongrout Dec 15, 2019
3be3916
Clean up some old TODOs
jasongrout Dec 16, 2019
9e044b3
Change kernel.connectComm to kernel.createComm and add a new hasComm …
jasongrout Oct 1, 2019
b97ec47
Allow reconnections for disconnected kernels
jasongrout Dec 17, 2019
1a2dde3
Only try to reconnect if the kernel connection is not disposed
jasongrout Dec 17, 2019
5250848
Delete old test comment
jasongrout Dec 17, 2019
b8f2a21
Update testEmission to use optional chaining and null coalescing.
jasongrout Dec 17, 2019
1147fb4
Fix skipped test
jasongrout Dec 17, 2019
2ff170e
Fix some problematic logic around reconnections exposed by the tests
jasongrout Dec 17, 2019
b12665f
Fix comm test
jasongrout Dec 17, 2019
a3ee507
Test sessionContext shutdownOnDispose
jasongrout Dec 17, 2019
a0930fd
Clean out more TODO notes.
jasongrout Dec 17, 2019
8a5712d
Change .getSpec() to just .spec, to mirror the .info promise.
jasongrout Dec 17, 2019
06c4251
Resolve another TODO item by deciding against it.
jasongrout Dec 17, 2019
49b96ae
Make the session and kernel interfaces more consistent
jasongrout Dec 17, 2019
947a00c
Fix kernel connection spec promise calls.
jasongrout Dec 17, 2019
3334567
Fix a few more tests from the session manager signature changes.
jasongrout Dec 17, 2019
897635c
Another pass updating the services readme.
jasongrout Dec 17, 2019
bebcf00
Separate out the kernel and session creation vs connection options in…
jasongrout Dec 17, 2019
e751b95
Make slots class methods since we are now passing in the `this` conte…
jasongrout Dec 17, 2019
76a15dc
Restore original jest timeouts.
jasongrout Dec 18, 2019
e2ea578
Add connectionStatusChanged signal to session context.
jasongrout Dec 18, 2019
e999cf1
Remove debug logging.
jasongrout Dec 18, 2019
f4ff2af
Add a convenience session context .kernelDisplayStatus
jasongrout Dec 18, 2019
8d8b069
Fix an error where the handler used a variable before it was declared.
jasongrout Dec 18, 2019
11b86ee
Merge remote-tracking branch 'origin/master' into sessionpersistence
jasongrout Dec 18, 2019
9202a78
Fix compile issues from a mis-merge.
jasongrout Dec 18, 2019
e6f0a24
Merge remote-tracking branch 'origin/master' into sessionpersistence
jasongrout Dec 19, 2019
1fa189e
Remove obsolete test
jasongrout Dec 19, 2019
8635f64
Linting fixes
jasongrout Dec 19, 2019
0ad63f3
When creating a test session context, make sure the spec manager is r…
jasongrout Dec 19, 2019
7a8e4bb
Explicitly test kernel preference starting values to have the right d…
jasongrout Dec 19, 2019
dd5310e
Fix usage examples.
jasongrout Dec 19, 2019
bb0bd2c
Add tests for session context kernelDisplayName and kernelDisplayStatus
jasongrout Dec 19, 2019
7bbc7e8
Move example code for services into tested files.
jasongrout Dec 20, 2019
634f440
Service manager ready should depend on kernelspec manager ready.
jasongrout Dec 20, 2019
446f056
Add some more documentation to the services readme.
jasongrout Dec 20, 2019
ab45e19
[skip ci] spelling
Dec 20, 2019
d2cee9c
Streamline test that often times out on Windows and raise timeout limit
jasongrout Dec 20, 2019
967180f
Merge branch 'sessionpersistence' of github.com:jasongrout/jupyterlab…
jasongrout Dec 20, 2019
f18e0fd
Up timeouts on tests we seem to be getting timeouts on in the windows…
jasongrout Dec 20, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
42 changes: 26 additions & 16 deletions examples/cell/src/index.ts
Expand Up @@ -10,7 +10,7 @@ import '@jupyterlab/cells/style/index.css';
import '@jupyterlab/theme-light-extension/style/index.css';
import '../index.css';

import { ClientSession, Toolbar } from '@jupyterlab/apputils';
import { SessionContext, Toolbar } from '@jupyterlab/apputils';

import { CodeCellModel, CodeCell } from '@jupyterlab/cells';

Expand All @@ -28,15 +28,25 @@ import {
standardRendererFactories as initialFactories
} from '@jupyterlab/rendermime';

import { SessionManager } from '@jupyterlab/services';
import {
SessionManager,
KernelManager,
KernelSpecManager
} from '@jupyterlab/services';

import { CommandRegistry } from '@lumino/commands';

import { BoxPanel, Widget } from '@lumino/widgets';

function main(): void {
const manager = new SessionManager();
const session = new ClientSession({ manager, name: 'Example' });
const kernelManager = new KernelManager();
const specsManager = new KernelSpecManager();
const sessionManager = new SessionManager({ kernelManager });
const sessionContext = new SessionContext({
sessionManager,
specsManager,
name: 'Example'
});
const mimeService = new CodeMirrorMimeTypeService();

// Initialize the command registry with the bindings.
Expand All @@ -60,23 +70,23 @@ function main(): void {
model: new CodeCellModel({})
}).initializeState();

// Handle the mimeType for the current kernel.
session.kernelChanged.connect(() => {
void session.kernel.ready.then(() => {
const lang = session.kernel.info.language_info;
// Handle the mimeType for the current kernel asynchronously.
sessionContext.kernelChanged.connect(() => {
void sessionContext.session?.kernel?.info.then(info => {
const lang = info.language_info;
const mimeType = mimeService.getMimeTypeByLanguage(lang);
cellWidget.model.mimeType = mimeType;
});
});

// Use the default kernel.
session.kernelPreference = { autoStartDefault: true };
sessionContext.kernelPreference = { autoStartDefault: true };

// Set up a completer.
const editor = cellWidget.editor;
const model = new CompleterModel();
const completer = new Completer({ editor, model });
const connector = new KernelConnector({ session });
const connector = new KernelConnector({ session: sessionContext.session });
const handler = new CompletionHandler({ completer, connector });

// Set the handler's editor.
Expand All @@ -88,10 +98,10 @@ function main(): void {
// Create a toolbar for the cell.
const toolbar = new Toolbar();
toolbar.addItem('spacer', Toolbar.createSpacerItem());
toolbar.addItem('interrupt', Toolbar.createInterruptButton(session));
toolbar.addItem('restart', Toolbar.createRestartButton(session));
toolbar.addItem('name', Toolbar.createKernelNameItem(session));
toolbar.addItem('status', Toolbar.createKernelStatusItem(session));
toolbar.addItem('interrupt', Toolbar.createInterruptButton(sessionContext));
toolbar.addItem('restart', Toolbar.createRestartButton(sessionContext));
toolbar.addItem('name', Toolbar.createKernelNameItem(sessionContext));
toolbar.addItem('status', Toolbar.createKernelStatusItem(sessionContext));

// Lay out the widgets.
const panel = new BoxPanel();
Expand Down Expand Up @@ -120,7 +130,7 @@ function main(): void {
}
});
commands.addCommand('run:cell', {
execute: () => CodeCell.execute(cellWidget, session)
execute: () => CodeCell.execute(cellWidget, sessionContext)
});

commands.addKeyBinding({
Expand All @@ -135,7 +145,7 @@ function main(): void {
});

// Start up the kernel.
void session.initialize().then(() => {
void sessionContext.initialize().then(() => {
console.log('Example started!');
});
}
Expand Down
4 changes: 3 additions & 1 deletion examples/chrome-example-test.js
Expand Up @@ -20,9 +20,11 @@ async function main() {

const handleMessage = async msg => {
const text = msg.text();
console.log(`>> ${text}`);
if (msg.type() === 'error') {
console.log(`ERROR>> ${text}`);
errored = true;
} else {
console.log(`>> ${text}`);
}
const lower = text.toLowerCase();
if (lower === 'example started!' || lower === 'test complete!') {
Expand Down
14 changes: 6 additions & 8 deletions examples/notebook/src/commands.ts
Expand Up @@ -121,26 +121,24 @@ export const SetupCommands = (
});
commands.addCommand(cmdIds.interrupt, {
label: 'Interrupt',
execute: async () => {
if (nbWidget.context.session.kernel) {
await nbWidget.context.session.kernel.interrupt();
}
}
execute: async () =>
nbWidget.context.sessionContext.session?.kernel?.interrupt()
});
commands.addCommand(cmdIds.restart, {
label: 'Restart Kernel',
execute: () => nbWidget.context.session.restart()
execute: async () =>
nbWidget.context.sessionContext.session?.kernel?.restart()
});
commands.addCommand(cmdIds.switchKernel, {
label: 'Switch Kernel',
execute: () => nbWidget.context.session.selectKernel()
execute: async () => nbWidget.context.sessionContext.selectKernel()
});
commands.addCommand(cmdIds.runAndAdvance, {
label: 'Run and Advance',
execute: () => {
return NotebookActions.runAndAdvance(
nbWidget.content,
nbWidget.context.session
nbWidget.context.sessionContext
);
}
});
Expand Down
4 changes: 3 additions & 1 deletion examples/notebook/src/index.ts
Expand Up @@ -111,7 +111,9 @@ function createApp(manager: ServiceManager.IManager): void {
nbWidget.content.activeCell && nbWidget.content.activeCell.editor;
const model = new CompleterModel();
const completer = new Completer({ editor, model });
const connector = new KernelConnector({ session: nbWidget.session });
const connector = new KernelConnector({
session: nbWidget.sessionContext.session
});
const handler = new CompletionHandler({ completer, connector });

// Set the handler's editor.
Expand Down
41 changes: 25 additions & 16 deletions examples/test_examples.py
Expand Up @@ -5,46 +5,55 @@
in ../packages/services/examples. We import each of the applications
and add instrument them with a puppeteer test that makes sure
there are no console errors or uncaught errors prior to a sentinel
string being printed.
string being printed (see chrome-example-test.js for the sentinel strings
checked before the browser.close() call).
"""
import argparse
import glob
import os.path as osp
import subprocess
import sys
import tempfile

here = osp.abspath(osp.dirname(__file__))

def header(path):
def header(path, cwd = ''):
test_name = osp.basename(path)
print('\n'.join((
'\n',
'*' * 40,
'Starting %s test' % test_name,
'Starting %s test in %s' % (test_name, cwd),
'*' * 40
)), flush=True)

def main():
parser = argparse.ArgumentParser()
parser.add_argument("--testPath", help="paths containing this string are tested")
args = parser.parse_args()

paths = [i for i in glob.glob('%s/*' % here) if osp.isdir(i)]

services_dir = osp.abspath(osp.join(here, '../packages/services/examples'))
paths += [i for i in glob.glob('%s/*' % services_dir)]
if args.testPath:
paths = [p for p in paths if args.testPath in p]

print('Testing %s'%paths)

count = 0
for path in sorted(paths):
if osp.basename(path) == 'node':
header(path)
runner = osp.join(path, 'main.py')
subprocess.check_call([sys.executable, runner])
count += 1
continue

if not osp.exists(osp.join(path, 'main.py')):
continue

count += 1
header(path)
runner = osp.join(here, 'example_check.py')
subprocess.check_call([sys.executable, runner, path])
with tempfile.TemporaryDirectory() as cwd:
header(path)
runner = osp.join(path, 'main.py')
subprocess.check_call([sys.executable, runner])
count += 1
elif osp.exists(osp.join(path, 'main.py')):
with tempfile.TemporaryDirectory() as cwd:
header(path)
runner = osp.join(here, 'example_check.py')
subprocess.check_call([sys.executable, runner, path], cwd=cwd)
count += 1

print('\n\n%s tests complete!' % count)

Expand Down
2 changes: 2 additions & 0 deletions package.json
Expand Up @@ -69,11 +69,13 @@
"remove:package": "node buildutils/lib/remove-package.js",
"remove:sibling": "node buildutils/lib/remove-package.js",
"test": "lerna run test --scope \"@jupyterlab/test-*\" --concurrency 1 --stream",
"test:all": "lerna run test --scope \"@jupyterlab/test-*\" --concurrency 1 --stream --no-bail",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

"test:chrome": "lerna run test:chrome --scope \"@jupyterlab/test-*\" --concurrency 1 --stream",
"test:chrome-headless": "lerna run test:chrome-headless --scope \"@jupyterlab/test-*\" --concurrency 1 --stream",
"test:examples": "python examples/test_examples.py",
"test:firefox": "lerna run test:firefox --scope \"@jupyterlab/test-*\" --concurrency 1 --stream",
"test:ie": "lerna run test:ie --scope \"@jupyterlab/test-*\" --concurrency 1 --stream",
"test:summary": "lerna run test --scope \"@jupyterlab/test-*\" --parallel --no-bail | grep -Ei '.* test.*(failed|passed|total|completed|skipped)' | sort",
"tslint": "tslint --fix -c tslint.json --project tsconfigbase.json '**/*{.ts,.tsx}'",
"tslint:check": "tslint -c tslint.json --project tsconfigbase.json '**/*{.ts,.tsx}'",
"update:dependency": "node buildutils/lib/update-dependency.js --lerna",
Expand Down
2 changes: 1 addition & 1 deletion packages/apputils/src/index.ts
@@ -1,7 +1,6 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.

export * from './clientsession';
export * from './clipboard';
export * from './collapse';
export * from './commandlinker';
Expand All @@ -14,6 +13,7 @@ export * from './inputdialog';
export * from './mainareawidget';
export * from './printing';
export * from './sanitizer';
export * from './sessioncontext';
export * from './spinner';
export * from './splash';
export * from './styling';
Expand Down