Fixed Notebooks regression: invalid kernels aren't handled #3404 (#3447)

* Fixed the not supported kernel in saved notebook

* Resolve PR comment.
This commit is contained in:
Yurong He
2018-12-05 10:54:37 -08:00
committed by GitHub
parent 971b5111e7
commit 8f817ce689

View File

@@ -140,9 +140,14 @@ export class SparkMagicContexts {
* @param savedKernelInfo kernel info loaded from
*/
public static getDefaultKernel(specs: nb.IAllKernels, connectionInfo: IConnectionProfile, savedKernelInfo: nb.IKernelInfo, notificationService: INotificationService): nb.IKernelSpec {
let defaultKernel = specs.kernels.find((kernel) => kernel.name === specs.defaultKernel);
let foundSavedKernelInSpecs;
let defaultKernel;
if (specs) {
foundSavedKernelInSpecs = specs.kernels.find((kernel) => kernel.name === savedKernelInfo.name);
defaultKernel = specs.kernels.find((kernel) => kernel.name === specs.defaultKernel);
}
let profile = connectionInfo as IConnectionProfile;
if (specs && connectionInfo && profile.providerName === notebookConstants.hadoopKnoxProviderName) {
if (foundSavedKernelInSpecs && specs && connectionInfo && profile.providerName === notebookConstants.hadoopKnoxProviderName) {
// set default kernel to default spark kernel if profile exists
// otherwise, set default to kernel info loaded from existing file
defaultKernel = !savedKernelInfo ? specs.kernels.find((spec) => spec.name === notebookConstants.defaultSparkKernel) : savedKernelInfo;