Check kernel dependencies when a new session is started (#16040)

* check dependencies when a new session is started

* fix test

* fix issue when kernel spec is not found
This commit is contained in:
Lucy Zhang
2021-07-09 12:51:21 -07:00
committed by GitHub
parent e206eb81a3
commit 6c5d35eaae
3 changed files with 8 additions and 1 deletions

View File

@@ -476,7 +476,7 @@ export class JupyterServerInstallation implements IJupyterServerInstallation {
await fs.remove(this._oldPythonInstallationPath);
this._upgradeInProcess = false;
} else {
} else if (!installSettings.packageUpgradeOnly) {
await vscode.commands.executeCommand('notebook.action.restartJupyterNotebookSessions');
}
})

View File

@@ -129,6 +129,12 @@ export class JupyterSessionManager implements nb.SessionManager {
// no-op
return Promise.reject(new Error(localize('errorStartBeforeReady', "Cannot start a session, the manager is not yet initialized")));
}
// Prompt for Python Install to check that all dependencies are installed.
// This prevents the kernel from getting stuck if a user deletes a dependency after the server has been started.
let kernelDisplayName: string = this.specs?.kernels.find(k => k.name === options.kernelName)?.display_name;
await this._installation?.promptForPythonInstall(kernelDisplayName);
let sessionImpl = await this._sessionManager.startNew(options);
let jupyterSession = new JupyterSession(sessionImpl, this._installation, skipSettingEnvironmentVars, this._installation?.pythonEnvVarPath);
await jupyterSession.messagesComplete;

View File

@@ -115,6 +115,7 @@ describe('Jupyter Session Manager', function (): void {
}
};
mockJupyterManager.setup(m => m.startNew(TypeMoq.It.isAny())).returns(() => Promise.resolve(expectedSessionInfo));
mockJupyterManager.setup(m => m.specs).returns(() => undefined);
// When I call startSession
let session = await sessionManager.startNew(sessionOptions, true);