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

Give kernel connection options to a session connection #7820

Merged
merged 3 commits into from Jan 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 9 additions & 5 deletions packages/help-extension/src/index.tsx
Expand Up @@ -192,16 +192,20 @@ function activate(
if (!sessionModel.kernel || kernelInfoCache.has(sessionModel.kernel.name)) {
return;
}
const session = serviceManager.sessions.connectTo({ model: sessionModel });
// Note: .ready implies session.kernel.info is non-null
void session.kernel!.info.then(kernelInfo => {
const session = serviceManager.sessions.connectTo({
model: sessionModel,
kernelConnectionOptions: { handleComms: false }
});

void session.kernel?.info.then(kernelInfo => {
const name = session.kernel!.name;

// Check the cache second time so that, if two callbacks get scheduled,
// they don't try to add the same commands.
if (kernelInfoCache.has(sessionModel.kernel!.name)) {
if (kernelInfoCache.has(name)) {
return;
}
// Set the Kernel Info cache.
const name = session.kernel!.name;
kernelInfoCache.set(name, kernelInfo);

// Utility function to check if the current widget
Expand Down
6 changes: 6 additions & 0 deletions packages/services/src/session/default.ts
Expand Up @@ -33,6 +33,7 @@ export class SessionConnection implements Session.ISessionConnection {
this._username = options.username ?? '';
this._clientId = options.clientId ?? UUID.uuid4();
this._connectToKernel = options.connectToKernel;
this._kernelConnectionOptions = options.kernelConnectionOptions ?? {};
this.serverSettings =
options.serverSettings ?? ServerConnection.makeSettings();
this.setupKernel(options.model.kernel);
Expand Down Expand Up @@ -305,6 +306,7 @@ export class SessionConnection implements Session.ISessionConnection {
return;
}
const kc = this._connectToKernel({
...this._kernelConnectionOptions,
model,
username: this._username,
clientId: this._clientId,
Expand Down Expand Up @@ -421,4 +423,8 @@ export class SessionConnection implements Session.ISessionConnection {
private _connectToKernel: (
options: Kernel.IKernelConnection.IOptions
) => Kernel.IKernelConnection;
private _kernelConnectionOptions: Omit<
Kernel.IKernelConnection.IOptions,
'model' | 'username' | 'clientId' | 'serverSettings'
>;
}
16 changes: 12 additions & 4 deletions packages/services/src/session/session.ts
Expand Up @@ -186,6 +186,13 @@ export namespace ISessionConnection {
*/
model: IModel;

/**
* Connects to an existing kernel
*/
connectToKernel(
options: Kernel.IKernelConnection.IOptions
): Kernel.IKernelConnection;

/**
* The server settings.
*/
Expand All @@ -202,11 +209,12 @@ export namespace ISessionConnection {
clientId?: string;

/**
* Connects to an existing kernel
* Kernel connection options
*/
connectToKernel(
options: Kernel.IKernelConnection.IOptions
): Kernel.IKernelConnection;
kernelConnectionOptions?: Omit<
Kernel.IKernelConnection.IOptions,
'model' | 'username' | 'clientId' | 'serverSettings'
>;
}

/**
Expand Down