Skip to content
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.
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 switchKernel = async (newKernel: KernelSpecInterpreter) => {
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 (_, __) => switchKernel(kernel!));
}
}
}