Skip to content

Add ability to pass interpreter into kernel launcher #11482

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
10 changes: 8 additions & 2 deletions src/client/datascience/kernel-launcher/kernelLauncher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import * as uuid from 'uuid/v4';
import { IFileSystem } from '../../common/platform/types';
import { IProcessServiceFactory, IPythonExecutionFactory } from '../../common/process/types';
import { Resource } from '../../common/types';
import { PythonInterpreter } from '../../interpreter/contracts';
import { captureTelemetry } from '../../telemetry';
import { Telemetry } from '../constants';
import { IJupyterKernelSpec } from '../types';
Expand All @@ -30,15 +31,20 @@ export class KernelLauncher implements IKernelLauncher {
) {}

@captureTelemetry(Telemetry.KernelLauncherPerf)
public async launch(kernelSpec: IJupyterKernelSpec, resource: Resource): Promise<IKernelProcess> {
public async launch(
kernelSpec: IJupyterKernelSpec,
resource: Resource,
interpreter?: PythonInterpreter
): Promise<IKernelProcess> {
const connection = await this.getKernelConnection();
const kernelProcess = new KernelProcess(
this.pythonExecutionFactory,
this.processExecutionFactory,
this.file,
connection,
kernelSpec,
resource
resource,
interpreter
);
await kernelProcess.launch();
return kernelProcess;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { IDisposable } from 'monaco-editor';
import { IPythonExecutionFactory, ObservableExecutionResult } from '../../common/process/types';
import { Resource } from '../../common/types';
import { noop } from '../../common/utils/misc';
import { PythonInterpreter } from '../../interpreter/contracts';
import { KernelLauncherDaemonModule } from '../constants';
import { IJupyterKernelSpec } from '../types';
import { PythonKernelDaemon } from './kernelDaemon';
Expand All @@ -25,12 +26,12 @@ export class PythonKernelLauncherDaemon implements IDisposable {
constructor(@inject(IPythonExecutionFactory) private readonly pythonExecutionFactory: IPythonExecutionFactory) {}
public async launch(
resource: Resource,
kernelSpec: IJupyterKernelSpec
kernelSpec: IJupyterKernelSpec,
interpreter?: PythonInterpreter
): Promise<{ observableResult: ObservableExecutionResult<string>; daemon: IPythonKernelDaemon }> {
const pythonPath = kernelSpec.argv[0];
const daemon = await this.pythonExecutionFactory.createDaemon<IPythonKernelDaemon>({
daemonModule: KernelLauncherDaemonModule,
pythonPath: pythonPath,
pythonPath: interpreter?.path,
daemonClass: PythonKernelDaemon,
dedicated: true,
resource
Expand Down
7 changes: 5 additions & 2 deletions src/client/datascience/kernel-launcher/kernelProcess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { IFileSystem, TemporaryFile } from '../../common/platform/types';
import { IProcessServiceFactory, IPythonExecutionFactory, ObservableExecutionResult } from '../../common/process/types';
import { Resource } from '../../common/types';
import { noop, swallowExceptions } from '../../common/utils/misc';
import { PythonInterpreter } from '../../interpreter/contracts';
import { IJupyterKernelSpec } from '../types';
import { findIndexOfConnectionFile } from './kernelFinder';
import { PythonKernelLauncherDaemon } from './kernelLauncherDaemon';
Expand Down Expand Up @@ -48,7 +49,8 @@ export class KernelProcess implements IKernelProcess {
private readonly file: IFileSystem,
private readonly _connection: IKernelConnection,
kernelSpec: IJupyterKernelSpec,
private readonly resource: Resource
private readonly resource: Resource,
private readonly interpreter?: PythonInterpreter
) {
this.originalKernelSpec = kernelSpec;
this._kernelSpec = cloneDeep(kernelSpec);
Expand Down Expand Up @@ -131,7 +133,8 @@ export class KernelProcess implements IKernelProcess {
this.pythonKernelLauncher = new PythonKernelLauncherDaemon(this.pythonExecutionFactory);
const { observableResult, daemon } = await this.pythonKernelLauncher.launch(
this.resource,
this._kernelSpec
this._kernelSpec,
this.interpreter
);
this.kernelDaemon = daemon;
exeObs = observableResult;
Expand Down
7 changes: 6 additions & 1 deletion src/client/datascience/kernel-launcher/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,16 @@ import { CancellationToken, Event } from 'vscode';
import { InterpreterUri } from '../../common/installer/types';
import { ObservableExecutionResult } from '../../common/process/types';
import { IAsyncDisposable, IDisposable, Resource } from '../../common/types';
import { PythonInterpreter } from '../../interpreter/contracts';
import { IJupyterKernelSpec } from '../types';

export const IKernelLauncher = Symbol('IKernelLauncher');
export interface IKernelLauncher {
launch(kernelSpec: IJupyterKernelSpec, resource: Resource): Promise<IKernelProcess>;
launch(
kernelSpec: IJupyterKernelSpec,
resource: Resource,
interpreter?: PythonInterpreter
): Promise<IKernelProcess>;
}

export interface IKernelConnection {
Expand Down