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

Add progress indicator when switching kernels #9134

Merged
merged 3 commits into from
Dec 16, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -397,5 +397,6 @@
"DataScience.fallBackToRegisterAndUseActiveInterpeterAsKernel": "Couldn't find kernel '{0}' that the notebook was created with. Registering a new kernel using the current interpreter.",
"DataScience.fallBackToPromptToUseActiveInterpreterOrSelectAKernel": "Couldn't find kernel '{0}' that the notebook was created with.",
"DataScience.selectKernel": "Select a Kernel",
"products.installingModule": "Installing {0}"
"products.installingModule": "Installing {0}",
"DataScience.switchingKernelProgress": "Switching Kenel to '{0}'"
}
1 change: 1 addition & 0 deletions src/client/common/utils/localize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ export namespace DataScience {
export const fallBackToRegisterAndUseActiveInterpeterAsKernel = localize('DataScience.fallBackToRegisterAndUseActiveInterpeterAsKernel', 'Couldn\'t find kernel \'{0}\' that the notebook was created with. Registering a new kernel using the current interpreter.');
export const fallBackToPromptToUseActiveInterpreterOrSelectAKernel = localize('DataScience.fallBackToPromptToUseActiveInterpreterOrSelectAKernel', 'Couldn\'t find kernel \'{0}\' that the notebook was created with.');
export const jupyterStartTimedout = localize('DataScience.jupyterStartTimedout', 'Starting Jupyter has timedout. Please check the \'Jupyter\' output panel for further details.');
export const switchingKernelProgress = localize('DataScience.switchingKernelProgress', 'Switching Kenel to \'{0}\'');
}

export namespace DebugConfigStrings {
Expand Down
29 changes: 21 additions & 8 deletions src/client/datascience/interactive-common/interactiveBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { injectable, unmanaged } from 'inversify';
import * as os from 'os';
import * as path from 'path';
import * as uuid from 'uuid/v4';
import { ConfigurationTarget, Event, EventEmitter, Position, Range, Selection, TextEditor, Uri, ViewColumn } from 'vscode';
import { ConfigurationTarget, Event, EventEmitter, Position, ProgressLocation, ProgressOptions, Range, Selection, TextEditor, Uri, ViewColumn } from 'vscode';
import { Disposable } from 'vscode-jsonrpc';
import * as vsls from 'vsls/vscode';

Expand Down Expand Up @@ -1300,15 +1300,28 @@ export abstract class InteractiveBase extends WebViewHost<IInteractiveWindowMapp
}

if (kernel && (kernel.kernelSpec || kernel.kernelModel) && this.notebook) {
if (kernel.interpreter) {
this.notebook.setInterpreter(kernel.interpreter);
}
const swtichKernel = async (newKernel: KernelSpecInterpreter) => {
DonJayamanne marked this conversation as resolved.
Show resolved Hide resolved
if (newKernel.interpreter) {
this.notebook!.setInterpreter(newKernel.interpreter);
}

// Change the kernel. A status update should fire that changes our display
await this.notebook.setKernelSpec(kernel.kernelSpec || kernel.kernelModel!);
// Change the kernel. A status update should fire that changes our display
await this.notebook!.setKernelSpec(newKernel.kernelSpec || newKernel.kernelModel!);

// Add in a new sys info
await this.addSysInfo(SysInfoReason.New);
// Add in a new sys info
await this.addSysInfo(SysInfoReason.New);
};

const kernelDisplayName = kernel.kernelSpec?.display_name || kernel.kernelModel?.display_name;
const kernelName = kernel.kernelSpec?.name || kernel.kernelModel?.name;
// One of them is bound to be non-empty.
const displayName = kernelDisplayName || kernelName || '';
const options: ProgressOptions = {
location: ProgressLocation.Notification,
cancellable: false,
title: localize.DataScience.switchingKernelProgress().format(displayName)
};
await this.applicationShell.withProgress(options, async (_, __) => swtichKernel(kernel!));
}
}
}