Skip to content

Commit 7419a20

Browse files
committed
Regular code building
1 parent 74f839d commit 7419a20

17 files changed

+64
-103
lines changed

src/client/datascience/constants.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,12 +173,9 @@ export namespace LiveShare {
173173
}
174174

175175
export namespace LiveShareCommands {
176-
export const isNotebookSupported = 'isNotebookSupported';
177-
export const isImportSupported = 'isImportSupported';
178-
export const isKernelCreateSupported = 'isKernelCreateSupported';
179-
export const isKernelSpecSupported = 'isKernelSpecSupported';
180176
export const connectToNotebookServer = 'connectToNotebookServer';
181177
export const getUsableJupyterPython = 'getUsableJupyterPython';
178+
export const enumerateVersions = 'enumerateVersions';
182179
export const executeObservable = 'executeObservable';
183180
export const getSysInfo = 'getSysInfo';
184181
export const serverResponse = 'serverResponse';

src/client/datascience/history/history.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ import {
5151
IJupyterVariable,
5252
IJupyterVariables,
5353
IJupyterVariablesResponse,
54+
IJupyterVersionCache,
5455
IMessageCell,
5556
INotebookExporter,
5657
INotebookImporter,
@@ -61,7 +62,6 @@ import {
6162
} from '../types';
6263
import { WebViewHost } from '../webViewHost';
6364
import { HistoryMessageListener } from './historyMessageListener';
64-
import { IJupyterVersionCache } from '../types';
6565
import {
6666
HistoryMessages,
6767
IAddedSysInfo,
@@ -1007,7 +1007,7 @@ export class History extends WebViewHost<IHistoryMapping> implements IHistory {
10071007
const knownDark = await this.isDark();
10081008

10091009
// Extract our options
1010-
const options = await this.historyProvider.getNotebookOptions(resource);
1010+
const options = await this.historyProvider.getNotebookOptions();
10111011

10121012
this.logger.logInformation('Connecting to jupyter server ...');
10131013

src/client/datascience/history/historyProvider.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export class HistoryProvider implements IHistoryProvider, IAsyncDisposable {
8181
throw new Error(localize.DataScience.pythonInteractiveCreateFailed());
8282
}
8383

84-
public async getNotebookOptions() : Promise<INotebookServerOptions> {
84+
public async getNotebookOptions(resource: Uri | undefined) : Promise<INotebookServerOptions> {
8585
// Find the settings that we are going to launch our server with
8686
const settings = this.configService.getSettings();
8787
let serverURI: string | undefined = settings.datascience.jupyterServerURI;
@@ -93,6 +93,7 @@ export class HistoryProvider implements IHistoryProvider, IAsyncDisposable {
9393
}
9494

9595
return {
96+
resource,
9697
uri: serverURI,
9798
useDefaultConfig,
9899
purpose: Identifiers.HistoryPurpose

src/client/datascience/history/historycommandlistener.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ export class HistoryCommandListener implements IDataScienceCommandListener {
240240
// create a brand new one.
241241
const version = await this.jupyterVersionCache.get(Uri.file(input));
242242
if (version) {
243-
server = await this.jupyterExecution.connectToNotebookServer(version, { useDefaultConfig, purpose: uuid() }, cancelToken);
243+
server = await this.jupyterExecution.connectToNotebookServer(version, { resource: Uri.file(input), useDefaultConfig, purpose: uuid() }, cancelToken);
244244

245245
// If that works, then execute all of the cells.
246246
const cells = Array.prototype.concat(... await Promise.all(ranges.map(r => {

src/client/datascience/jupyter/jupyterCommand.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22
// Licensed under the MIT License.
33
'use strict';
44
import { inject, injectable } from 'inversify';
5-
import { CancellationToken, Uri } from 'vscode';
6-
import * as fs from 'fs-extra';
7-
import * as os from 'os';
85
import * as path from 'path';
6+
import { CancellationToken, Uri } from 'vscode';
97

108
import { Cancellation } from '../../../client/common/cancellation';
119
import { IWorkspaceService } from '../../common/application/types';
@@ -20,12 +18,11 @@ import {
2018
ObservableExecutionResult,
2119
SpawnOptions
2220
} from '../../common/process/types';
23-
import { IConfigurationService, IDisposableRegistry, IDisposable } from '../../common/types';
21+
import { IConfigurationService, IDisposable, IDisposableRegistry } from '../../common/types';
2422
import { IEnvironmentActivationService } from '../../interpreter/activation/types';
2523
import { IInterpreterService, IKnownSearchPathsForInterpreters, PythonInterpreter } from '../../interpreter/contracts';
2624
import { JupyterCommands, RegExpValues } from '../constants';
2725
import { IJupyterCommand, IJupyterCommandFactory } from '../types';
28-
import { string } from 'prop-types';
2926

3027
// JupyterCommand objects represent some process that can be launched that should be guaranteed to work because it
3128
// was found by testing it previously
@@ -249,7 +246,6 @@ export class JupyterCommandFactory implements IJupyterCommandFactory, IDisposabl
249246
return `${command}:${interpreter.path}:${interpreter.displayName ? interpreter.displayName : interpreter.envName}`;
250247
}
251248

252-
253249
private supportsSearchingForCommands(): boolean {
254250
if (this.configuration) {
255251
const settings = this.configuration.getSettings();

src/client/datascience/jupyter/jupyterConnection.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import '../../common/extensions';
55

66
import { ChildProcess } from 'child_process';
77
import * as path from 'path';
8-
import { CancellationToken, Disposable, Event, EventEmitter, Uri } from 'vscode';
8+
import { CancellationToken, Disposable, Event, EventEmitter } from 'vscode';
99

1010
import { CancellationError } from '../../common/cancellation';
1111
import { IFileSystem } from '../../common/platform/types';

src/client/datascience/jupyter/jupyterExecution.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ import { CancellationToken, Event, EventEmitter, Uri } from 'vscode';
1212

1313
import { ILiveShareApi, IWorkspaceService } from '../../common/application/types';
1414
import { Cancellation, CancellationError } from '../../common/cancellation';
15-
import { traceInfo, traceWarning } from '../../common/logger';
15+
import { traceInfo } from '../../common/logger';
1616
import { IFileSystem, TemporaryDirectory } from '../../common/platform/types';
17-
import { IProcessService, IProcessServiceFactory, IPythonExecutionFactory, SpawnOptions } from '../../common/process/types';
17+
import { IProcessServiceFactory, IPythonExecutionFactory, SpawnOptions } from '../../common/process/types';
1818
import { IAsyncDisposableRegistry, IConfigurationService, IDisposableRegistry, ILogger } from '../../common/types';
1919
import * as localize from '../../common/utils/localize';
2020
import { noop } from '../../common/utils/misc';
@@ -25,7 +25,6 @@ import { captureTelemetry, sendTelemetryEvent } from '../../telemetry';
2525
import { JupyterCommands, RegExpValues, Telemetry } from '../constants';
2626
import {
2727
IConnection,
28-
IJupyterCommand,
2928
IJupyterCommandFactory,
3029
IJupyterExecution,
3130
IJupyterKernelSpec,
@@ -101,6 +100,7 @@ export class JupyterExecutionBase implements IJupyterExecution {
101100

102101
// Populate the launch info that we are starting our server with
103102
const launchInfo: INotebookServerLaunchInfo = {
103+
resource: options && options.resource,
104104
connectionInfo: startInfo.connection,
105105
currentInterpreter: version.interpreter,
106106
kernelSpec: startInfo.kernelSpec,

src/client/datascience/jupyter/jupyterExecutionFactory.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Licensed under the MIT License.
33
'use strict';
44
import { inject, injectable } from 'inversify';
5-
import { CancellationToken, Event, EventEmitter, Uri } from 'vscode';
5+
import { CancellationToken, Event, EventEmitter } from 'vscode';
66

77
import { ILiveShareApi, IWorkspaceService } from '../../common/application/types';
88
import { IFileSystem } from '../../common/platform/types';
@@ -14,19 +14,19 @@ import {
1414
IDisposableRegistry,
1515
ILogger
1616
} from '../../common/types';
17-
import { IInterpreterService, IKnownSearchPathsForInterpreters, PythonInterpreter } from '../../interpreter/contracts';
17+
import { IInterpreterService, IKnownSearchPathsForInterpreters } from '../../interpreter/contracts';
1818
import { IServiceContainer } from '../../ioc/types';
1919
import {
2020
IJupyterCommandFactory,
2121
IJupyterExecution,
2222
IJupyterSessionManager,
23+
IJupyterVersion,
2324
INotebookServer,
2425
INotebookServerOptions
2526
} from '../types';
2627
import { GuestJupyterExecution } from './liveshare/guestJupyterExecution';
2728
import { HostJupyterExecution } from './liveshare/hostJupyterExecution';
2829
import { IRoleBasedObject, RoleBasedFactory } from './liveshare/roleBasedFactory';
29-
import { IJupyterVersion } from '../types';
3030

3131
interface IJupyterExecutionInterface extends IRoleBasedObject, IJupyterExecution {
3232

@@ -99,6 +99,11 @@ export class JupyterExecutionFactory implements IJupyterExecution, IAsyncDisposa
9999
return this.sessionChangedEventEmitter.event;
100100
}
101101

102+
public async enumerateVersions(serverURI?: string) : Promise<IJupyterVersion[]> {
103+
const execution = await this.executionFactory.get();
104+
return execution.enumerateVersions(serverURI);
105+
}
106+
102107
public async dispose() : Promise<void> {
103108
// Dispose of our execution object
104109
const execution = await this.executionFactory.get();

src/client/datascience/jupyter/jupyterExporter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,6 @@ export class JupyterExporter implements INotebookExporter {
184184
private async extractPythonMainVersion(resource: Uri | undefined): Promise<number> {
185185
// Use the active interpreter
186186
const usableInterpreter = await this.versionCache.get(resource);
187-
return usableInterpreter && usableInterpreter.version ? usableInterpreter.version.major : 3;
187+
return usableInterpreter && usableInterpreter.interpreter && usableInterpreter.interpreter.version ? usableInterpreter.interpreter.version.major : 3;
188188
}
189189
}

src/client/datascience/jupyter/jupyterImporter.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import { IFileSystem, IPlatformService } from '../../common/platform/types';
1212
import { IConfigurationService, IDisposableRegistry } from '../../common/types';
1313
import * as localize from '../../common/utils/localize';
1414
import { noop } from '../../common/utils/misc';
15-
import { CodeSnippits } from '../constants';
16-
import { IJupyterExecution, INotebookImporter } from '../types';
15+
import { CodeSnippits, JupyterCommands } from '../constants';
16+
import { IJupyterExecution, INotebookImporter, IJupyterCommandFactory } from '../types';
1717

1818
@injectable()
1919
export class JupyterImporter implements INotebookImporter {
@@ -39,6 +39,7 @@ export class JupyterImporter implements INotebookImporter {
3939
@inject(IDisposableRegistry) private disposableRegistry: IDisposableRegistry,
4040
@inject(IConfigurationService) private configuration: IConfigurationService,
4141
@inject(IJupyterExecution) private jupyterExecution: IJupyterExecution,
42+
@inject(IJupyterCommandFactory) private commandFactory: IJupyterCommandFactory,
4243
@inject(IWorkspaceService) private workspaceService: IWorkspaceService,
4344
@inject(IPlatformService) private readonly platform: IPlatformService
4445
) {
@@ -56,7 +57,7 @@ export class JupyterImporter implements INotebookImporter {
5657
}
5758

5859
// Use the jupyter nbconvert functionality to turn the notebook into a python file
59-
if (await this.jupyterExecution.isImportSupported(Uri.file(file))) {
60+
if (await this.commandFactory.getBestCommand(Uri.file(file), JupyterCommands.ConvertCommand)) {
6061
const fileOutput: string = await this.jupyterExecution.importNotebook(file, template);
6162
if (directoryChange) {
6263
return this.addDirectoryChange(fileOutput, directoryChange);

0 commit comments

Comments
 (0)