5
5
import type { nbformat } from '@jupyterlab/coreutils' ;
6
6
import { inject , injectable , named } from 'inversify' ;
7
7
import * as path from 'path' ;
8
- import { CancellationToken , CancellationTokenSource } from 'vscode' ;
8
+ import { CancellationToken } from 'vscode' ;
9
9
import { IWorkspaceService } from '../../common/application/types' ;
10
- import { wrapCancellationTokens } from '../../common/cancellation' ;
11
10
import { traceError , traceInfo } from '../../common/logger' ;
12
11
import { IPlatformService } from '../../common/platform/types' ;
13
12
import { IPythonExecutionFactory } from '../../common/process/types' ;
14
- import { IExtensionContext , IInstaller , InstallerResponse , IPathUtils , Product , Resource } from '../../common/types' ;
13
+ import { IExtensionContext , IPathUtils , Resource } from '../../common/types' ;
15
14
import { IEnvironmentVariablesProvider } from '../../common/variables/types' ;
16
15
import { IInterpreterLocatorService , IInterpreterService , KNOWN_PATH_SERVICE } from '../../interpreter/contracts' ;
17
16
import { captureTelemetry } from '../../telemetry' ;
@@ -20,7 +19,6 @@ import { Telemetry } from '../constants';
20
19
import { defaultKernelSpecName } from '../jupyter/kernels/helpers' ;
21
20
import { JupyterKernelSpec } from '../jupyter/kernels/jupyterKernelSpec' ;
22
21
import { IDataScienceFileSystem , IJupyterKernelSpec } from '../types' ;
23
- import { getKernelInterpreter } from './helpers' ;
24
22
import { IKernelFinder } from './types' ;
25
23
// tslint:disable-next-line:no-require-imports no-var-requires
26
24
const flatten = require ( 'lodash/flatten' ) as typeof import ( 'lodash/flatten' ) ;
@@ -56,7 +54,6 @@ export class KernelFinder implements IKernelFinder {
56
54
@inject ( IPlatformService ) private platformService : IPlatformService ,
57
55
@inject ( IDataScienceFileSystem ) private fs : IDataScienceFileSystem ,
58
56
@inject ( IPathUtils ) private readonly pathUtils : IPathUtils ,
59
- @inject ( IInstaller ) private installer : IInstaller ,
60
57
@inject ( IExtensionContext ) private readonly context : IExtensionContext ,
61
58
@inject ( IWorkspaceService ) private readonly workspaceService : IWorkspaceService ,
62
59
@inject ( IPythonExecutionFactory ) private readonly exeFactory : IPythonExecutionFactory ,
@@ -65,9 +62,7 @@ export class KernelFinder implements IKernelFinder {
65
62
@captureTelemetry ( Telemetry . KernelFinderPerf )
66
63
public async findKernelSpec (
67
64
resource : Resource ,
68
- kernelSpecMetadata ?: nbformat . IKernelspecMetadata ,
69
- cancelToken ?: CancellationToken ,
70
- ignoreDependencyCheck ?: boolean
65
+ kernelSpecMetadata ?: nbformat . IKernelspecMetadata
71
66
) : Promise < IJupyterKernelSpec | undefined > {
72
67
await this . readCache ( ) ;
73
68
let foundKernel : IJupyterKernelSpec | undefined ;
@@ -108,8 +103,7 @@ export class KernelFinder implements IKernelFinder {
108
103
109
104
this . writeCache ( ) . ignoreErrors ( ) ;
110
105
111
- // Verify that ipykernel is installed into the given kernelspec interpreter
112
- return ignoreDependencyCheck || ! foundKernel ? foundKernel : this . verifyIpyKernel ( foundKernel , cancelToken ) ;
106
+ return foundKernel ;
113
107
}
114
108
115
109
// Search all our local file system locations for installed kernel specs and return them
@@ -318,30 +312,6 @@ export class KernelFinder implements IKernelFinder {
318
312
return flatten ( fullPathResults ) ;
319
313
}
320
314
321
- // For the given kernelspec return back the kernelspec with ipykernel installed into it or error
322
- private async verifyIpyKernel (
323
- kernelSpec : IJupyterKernelSpec ,
324
- cancelToken ?: CancellationToken
325
- ) : Promise < IJupyterKernelSpec > {
326
- const interpreter = await getKernelInterpreter ( kernelSpec , this . interpreterService ) ;
327
-
328
- if ( await this . installer . isInstalled ( Product . ipykernel , interpreter ) ) {
329
- return kernelSpec ;
330
- } else {
331
- const token = new CancellationTokenSource ( ) ;
332
- const response = await this . installer . promptToInstall (
333
- Product . ipykernel ,
334
- interpreter ,
335
- wrapCancellationTokens ( cancelToken , token . token )
336
- ) ;
337
- if ( response === InstallerResponse . Installed ) {
338
- return kernelSpec ;
339
- }
340
- }
341
-
342
- throw new Error ( `IPyKernel not installed into interpreter ${ interpreter . displayName } ` ) ;
343
- }
344
-
345
315
private async getKernelSpecFromActiveInterpreter (
346
316
kernelName : string ,
347
317
resource : Resource
0 commit comments