Skip to content

Commit a707a35

Browse files
For now do not update the datascience code to use internal.scripts.vscode_datascience_helpers.*.
1 parent 98cf48b commit a707a35

File tree

4 files changed

+64
-23
lines changed

4 files changed

+64
-23
lines changed

src/client/datascience/jupyter/interpreter/jupyterCommand.ts

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
'use strict';
44
import { SpawnOptions } from 'child_process';
55
import { inject, injectable } from 'inversify';
6+
import * as path from 'path';
67
import { traceError } from '../../../common/logger';
7-
import { scripts as internalScripts } from '../../../common/process/internal';
88
import {
99
ExecutionResult,
1010
IProcessService,
@@ -13,6 +13,7 @@ import {
1313
IPythonExecutionService,
1414
ObservableExecutionResult
1515
} from '../../../common/process/types';
16+
import { EXTENSION_ROOT_DIR } from '../../../constants';
1617
import { IEnvironmentActivationService } from '../../../interpreter/activation/types';
1718
import { IInterpreterService, PythonInterpreter } from '../../../interpreter/contracts';
1819
import { JupyterCommands, PythonDaemonModule } from '../../constants';
@@ -97,10 +98,19 @@ class InterpreterJupyterCommand implements IJupyterCommand {
9798
args.join(' ').toLowerCase().startsWith('-m jupyter notebook')) ||
9899
(moduleName.toLowerCase() === 'notebook' && args.join(' ').toLowerCase().startsWith('-m notebook'))
99100
) {
100-
const [scriptArgs, parse] = internalScripts.vscode_datascience_helpers.jupyter_nbInstalled();
101101
try {
102-
const proc = await svc.exec(scriptArgs, {});
103-
if (parse(proc.stdout)) {
102+
const output = await svc.exec(
103+
[
104+
path.join(
105+
EXTENSION_ROOT_DIR,
106+
'pythonFiles',
107+
'vscode_datascience_helpers',
108+
'jupyter_nbInstalled.py'
109+
)
110+
],
111+
{}
112+
);
113+
if (output.stdout.toLowerCase().includes('available')) {
104114
return svc;
105115
}
106116
} catch (ex) {
@@ -253,17 +263,28 @@ export class InterpreterJupyterKernelSpecCommand extends InterpreterJupyterComma
253263
interpreter,
254264
bypassCondaExecution: true
255265
});
256-
const args = internalScripts.vscode_datascience_helpers.getJupyterKernels();
257-
return activatedEnv.exec(args, { ...options, throwOnStdErr: true });
266+
return activatedEnv.exec(
267+
[path.join(EXTENSION_ROOT_DIR, 'pythonFiles', 'vscode_datascience_helpers', 'getJupyterKernels.py')],
268+
{ ...options, throwOnStdErr: true }
269+
);
258270
}
259271
private async getKernelSpecVersion(interpreter: PythonInterpreter, options: SpawnOptions) {
260272
// Try getting kernels using python script, if that fails (even if there's output in stderr) rethrow original exception.
261273
const activatedEnv = await this.pythonExecutionFactory.createActivatedEnvironment({
262274
interpreter,
263275
bypassCondaExecution: true
264276
});
265-
const args = internalScripts.vscode_datascience_helpers.getJupyterKernelspecVersion();
266-
return activatedEnv.exec(args, { ...options, throwOnStdErr: true });
277+
return activatedEnv.exec(
278+
[
279+
path.join(
280+
EXTENSION_ROOT_DIR,
281+
'pythonFiles',
282+
'vscode_datascience_helpers',
283+
'getJupyterKernelspecVersion.py'
284+
)
285+
],
286+
{ ...options, throwOnStdErr: true }
287+
);
267288
}
268289
}
269290

src/client/datascience/jupyter/interpreter/jupyterCommandInterpreterExecutionService.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44
'use strict';
55

66
import { inject, injectable } from 'inversify';
7+
import * as path from 'path';
78
import { CancellationToken } from 'vscode';
89
import { Cancellation } from '../../../common/cancellation';
910
import { traceError, traceInfo, traceWarning } from '../../../common/logger';
1011
import { IFileSystem } from '../../../common/platform/types';
11-
import { scripts as internalScripts } from '../../../common/process/internal';
1212
import { IPythonExecutionFactory, ObservableExecutionResult, SpawnOptions } from '../../../common/process/types';
1313
import { DataScience } from '../../../common/utils/localize';
1414
import { noop } from '../../../common/utils/misc';
15+
import { EXTENSION_ROOT_DIR } from '../../../constants';
1516
import { IInterpreterService, PythonInterpreter } from '../../../interpreter/contracts';
1617
import { JupyterCommands, PythonDaemonModule } from '../../constants';
1718
import { IJupyterSubCommandExecutionService } from '../../types';
@@ -101,13 +102,13 @@ export class JupyterCommandFinderInterpreterExecutionService implements IJupyter
101102

102103
// We have a small python file here that we will execute to get the server info from all running Jupyter instances
103104
const newOptions: SpawnOptions = { mergeStdOutErr: true, token: token };
104-
const [args, parse] = internalScripts.vscode_datascience_helpers.getServerInfo();
105-
const serverInfoProc = await daemon.exec(args, newOptions);
105+
const file = path.join(EXTENSION_ROOT_DIR, 'pythonFiles', 'vscode_datascience_helpers', 'getServerInfo.py');
106+
const serverInfoString = await daemon.exec([file], newOptions);
106107

107108
let serverInfos: JupyterServerInfo[];
108109
try {
109110
// Parse out our results, return undefined if we can't suss it out
110-
serverInfos = parse(serverInfoProc.stdout) as JupyterServerInfo[];
111+
serverInfos = JSON.parse(serverInfoString.stdout.trim()) as JupyterServerInfo[];
111112
} catch (err) {
112113
traceWarning('Failed to parse JSON when getting server info out from getServerInfo.py', err);
113114
return;

src/client/datascience/jupyter/interpreter/jupyterInterpreterSubCommandExecutionService.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@
44
'use strict';
55

66
import { inject, injectable, named } from 'inversify';
7+
import * as path from 'path';
78
import { CancellationToken } from 'vscode';
89
import { Cancellation } from '../../../common/cancellation';
910
import { traceError, traceInfo, traceWarning } from '../../../common/logger';
1011
import { IFileSystem } from '../../../common/platform/types';
11-
import { scripts as internalScripts } from '../../../common/process/internal';
1212
import { IPythonExecutionFactory, ObservableExecutionResult, SpawnOptions } from '../../../common/process/types';
1313
import { IOutputChannel, IPathUtils, Product } from '../../../common/types';
1414
import { DataScience } from '../../../common/utils/localize';
1515
import { noop } from '../../../common/utils/misc';
16+
import { EXTENSION_ROOT_DIR } from '../../../constants';
1617
import { IInterpreterService, PythonInterpreter } from '../../../interpreter/contracts';
1718
import { sendTelemetryEvent } from '../../../telemetry';
1819
import { JUPYTER_OUTPUT_CHANNEL, PythonDaemonModule, Telemetry } from '../../constants';
@@ -125,13 +126,13 @@ export class JupyterInterpreterSubCommandExecutionService
125126

126127
// We have a small python file here that we will execute to get the server info from all running Jupyter instances
127128
const newOptions: SpawnOptions = { mergeStdOutErr: true, token: token };
128-
const [args, parse] = internalScripts.vscode_datascience_helpers.getServerInfo();
129-
const serverInfoProc = await daemon.exec(args, newOptions);
129+
const file = path.join(EXTENSION_ROOT_DIR, 'pythonFiles', 'vscode_datascience_helpers', 'getServerInfo.py');
130+
const serverInfoString = await daemon.exec([file], newOptions);
130131

131132
let serverInfos: JupyterServerInfo[];
132133
try {
133134
// Parse out our results, return undefined if we can't suss it out
134-
serverInfos = parse(serverInfoProc.stdout) as JupyterServerInfo[];
135+
serverInfos = JSON.parse(serverInfoString.stdout.trim()) as JupyterServerInfo[];
135136
} catch (err) {
136137
traceWarning('Failed to parse JSON when getting server info out from getServerInfo.py', err);
137138
return;
@@ -196,9 +197,18 @@ export class JupyterInterpreterSubCommandExecutionService
196197
return '';
197198
});
198199
// Possible we cannot import ipykernel for some reason. (use as backup option).
199-
const args = internalScripts.vscode_datascience_helpers.getJupyterKernels();
200200
const stdoutFromFileExecPromise = daemon
201-
.exec(args, spawnOptions)
201+
.exec(
202+
[
203+
path.join(
204+
EXTENSION_ROOT_DIR,
205+
'pythonFiles',
206+
'vscode_datascience_helpers',
207+
'getJupyterKernels.py'
208+
)
209+
],
210+
spawnOptions
211+
)
202212
.then((output) => output.stdout)
203213
.catch((fileEx) => {
204214
traceError('Failed to list kernels from getJupyterKernels.py', fileEx);

src/client/datascience/jupyter/jupyterVariables.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,17 @@
44
import { nbformat } from '@jupyterlab/coreutils';
55
import { JSONObject } from '@phosphor/coreutils';
66
import { inject, injectable } from 'inversify';
7+
import * as path from 'path';
78
import stripAnsi from 'strip-ansi';
89
import * as uuid from 'uuid/v4';
910

1011
import { Uri } from 'vscode';
1112
import { PYTHON_LANGUAGE } from '../../common/constants';
1213
import { traceError } from '../../common/logger';
1314
import { IFileSystem } from '../../common/platform/types';
14-
import { scripts as internalScripts } from '../../common/process/internal';
1515
import { IConfigurationService } from '../../common/types';
1616
import * as localize from '../../common/utils/localize';
17+
import { EXTENSION_ROOT_DIR } from '../../constants';
1718
import { Identifiers, Settings } from '../constants';
1819
import {
1920
ICell,
@@ -93,12 +94,20 @@ export class JupyterVariables implements IJupyterVariables {
9394
// Private methods
9495
// Load our python files for fetching variables
9596
private async loadVariableFiles(): Promise<void> {
96-
let args = internalScripts.vscode_datascience_helpers.getJupyterVariableDataFrameInfo();
97-
let file = args[0];
97+
let file = path.join(
98+
EXTENSION_ROOT_DIR,
99+
'pythonFiles',
100+
'vscode_datascience_helpers',
101+
'getJupyterVariableDataFrameInfo.py'
102+
);
98103
this.fetchDataFrameInfoScript = await this.fileSystem.readFile(file);
99104

100-
args = internalScripts.vscode_datascience_helpers.getJupyterVariableDataFrameInfo();
101-
file = args[0];
105+
file = path.join(
106+
EXTENSION_ROOT_DIR,
107+
'pythonFiles',
108+
'vscode_datascience_helpers',
109+
'getJupyterVariableDataFrameRows.py'
110+
);
102111
this.fetchDataFrameRowsScript = await this.fileSystem.readFile(file);
103112

104113
this.filesLoaded = true;

0 commit comments

Comments
 (0)