Treat Jupyter's Python 3 Ipykernel alias as Python 3. (#18943)

This commit is contained in:
Cory Rivera
2022-04-06 11:27:15 -07:00
committed by GitHub
parent 316798a9b5
commit 03d2e83250
2 changed files with 14 additions and 11 deletions

View File

@@ -39,6 +39,7 @@ import { AddCellEdit, CellOutputEdit, ConvertCellTypeEdit, DeleteCellEdit, MoveC
import { IUndoRedoService } from 'vs/platform/undoRedo/common/undoRedo';
import { deepClone } from 'vs/base/common/objects';
import { DotnetInteractiveLabel } from 'sql/workbench/api/common/notebooks/notebookUtils';
import { IPYKERNEL_DISPLAY_NAME } from 'sql/workbench/common/constants';
/*
* Used to control whether a message in a dialog/wizard is displayed as an error,
@@ -1345,19 +1346,20 @@ export class NotebookModel extends Disposable implements INotebookModel {
private sanitizeSavedKernelInfo(): void {
if (this._savedKernelInfo) {
let displayName = this._savedKernelInfo.display_name;
if (this._savedKernelInfo.display_name !== displayName) {
this._savedKernelInfo.display_name = displayName;
}
let standardKernel = this._standardKernels.find(kernel => kernel.displayName === displayName || displayName.startsWith(kernel.displayName));
if (standardKernel && this._savedKernelInfo.name && this._savedKernelInfo.name !== standardKernel.name) {
// Special case .NET Interactive kernel name to handle inconsistencies between notebook providers and jupyter kernel specs
if (this._savedKernelInfo.display_name === DotnetInteractiveLabel) {
this._savedKernelInfo.oldName = this._savedKernelInfo.name;
}
if (standardKernel) {
if (this._savedKernelInfo.name && this._savedKernelInfo.name !== standardKernel.name) {
// Special case .NET Interactive kernel name to handle inconsistencies between notebook providers and jupyter kernel specs
if (this._savedKernelInfo.display_name === DotnetInteractiveLabel) {
this._savedKernelInfo.oldName = this._savedKernelInfo.name;
}
this._savedKernelInfo.name = standardKernel.name;
this._savedKernelInfo.display_name = standardKernel.displayName;
this._savedKernelInfo.name = standardKernel.name;
this._savedKernelInfo.display_name = standardKernel.displayName;
} else if (displayName === IPYKERNEL_DISPLAY_NAME && this._savedKernelInfo.name === standardKernel.name) {
// Handle Jupyter alias for Python 3 kernel
this._savedKernelInfo.display_name = standardKernel.displayName;
}
}
}
}