Skip to content

Commit bb6899c

Browse files
authored
Add more logging for debugging to the nightly tests (#7315)
* Add more logging for debugging * Add some more logging * Add more logging * Fix linter
1 parent abf86f3 commit bb6899c

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

build/ci/vscode-python-nightly-flake-ci.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ variables:
2929
MOCHA_FILE: '$(Build.ArtifactStagingDirectory)/test-junit.xml' # All test files will write their JUnit xml output to this file, clobbering the last time it was written.
3030
MOCHA_REPORTER_JUNIT: true # Use the mocha-multi-reporters and send output to both console (spec) and JUnit (mocha-junit-reporter).
3131
VSC_PYTHON_LOG_FILE: '$(Build.ArtifactStagingDirectory)/pvsc.log'
32+
PTVSD_LOG_DIR: '$(Build.ArtifactStagingDirectory)' # Get the debugger to log output too
3233

3334
jobs:
3435

src/client/datascience/jupyter/jupyterDebugger.ts

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ export class JupyterDebugger implements IJupyterDebugger, ICellHashListener {
5757
// Try to connect to this notebook
5858
const config = await this.connect(notebook);
5959
if (config) {
60+
traceInfo('connected to notebook during debugging');
61+
6062
// First check if this is a live share session. Skip debugging attach on the guest
6163
// tslint:disable-next-line: no-any
6264
const hasRole = (notebook as any) as ILiveShareHasRole;
@@ -75,6 +77,8 @@ export class JupyterDebugger implements IJupyterDebugger, ICellHashListener {
7577
const importResults = await this.executeSilently(notebook, `import ptvsd\nptvsd.wait_for_attach()`);
7678
if (importResults.length === 0 || importResults[0].state === CellState.error) {
7779
traceWarning('PTVSD not found in path.');
80+
} else {
81+
this.traceCellResults('import startup', importResults);
7882
}
7983

8084
// Then enable tracing
@@ -119,6 +123,22 @@ export class JupyterDebugger implements IJupyterDebugger, ICellHashListener {
119123
}
120124
}
121125

126+
private traceCellResults(prefix: string, results: ICell[]) {
127+
if (results.length > 0 && results[0].data.cell_type === 'code') {
128+
const cell = results[0].data as nbformat.ICodeCell;
129+
const error = cell.outputs[0].evalue;
130+
if (error) {
131+
traceError(`${prefix} Error : ${error}`);
132+
} else {
133+
const data = cell.outputs[0].data;
134+
const text = cell.outputs[0].text;
135+
traceInfo(`${prefix} Output: ${text || JSON.stringify(data)}`);
136+
}
137+
} else {
138+
traceInfo(`${prefix} no output.`);
139+
}
140+
}
141+
122142
private async connect(notebook: INotebook): Promise<DebugConfiguration | undefined> {
123143
// If we already have configuration, we're already attached, don't do it again.
124144
let result = this.configs.get(notebook.resource.toString());
@@ -201,7 +221,8 @@ export class JupyterDebugger implements IJupyterDebugger, ICellHashListener {
201221
const ptvsdPathList = this.calculatePtvsdPathList(notebook);
202222

203223
if (ptvsdPathList && ptvsdPathList.length > 0) {
204-
await this.executeSilently(notebook, `import sys\r\nsys.path.extend([${ptvsdPathList}])\r\nsys.path`);
224+
const result = await this.executeSilently(notebook, `import sys\r\nsys.path.extend([${ptvsdPathList}])\r\nsys.path`);
225+
this.traceCellResults('Appending paths', result);
205226
}
206227
}
207228

@@ -243,6 +264,7 @@ export class JupyterDebugger implements IJupyterDebugger, ICellHashListener {
243264

244265
private parsePtvsdVersionInfo(cells: ICell[]): IPtvsdVersion | undefined {
245266
if (cells.length < 1 || cells[0].state !== CellState.finished) {
267+
this.traceCellResults('parsePtvsdVersionInfo', cells);
246268
return undefined;
247269
}
248270

@@ -262,6 +284,8 @@ export class JupyterDebugger implements IJupyterDebugger, ICellHashListener {
262284
}
263285
}
264286

287+
this.traceCellResults('parsingPtvsdVersionInfo', cells);
288+
265289
return undefined;
266290
}
267291

@@ -292,6 +316,7 @@ export class JupyterDebugger implements IJupyterDebugger, ICellHashListener {
292316
private async installPtvsd(notebook: INotebook): Promise<void> {
293317
// tslint:disable-next-line:no-multiline-string
294318
const ptvsdInstallResults = await this.executeSilently(notebook, `import sys\r\n!{sys.executable} -m pip install -U ptvsd`);
319+
traceInfo('Installing ptvsd');
295320

296321
if (ptvsdInstallResults.length > 0) {
297322
const installResultsString = this.extractOutput(ptvsdInstallResults[0]);
@@ -302,7 +327,7 @@ export class JupyterDebugger implements IJupyterDebugger, ICellHashListener {
302327
return;
303328
}
304329
}
305-
330+
this.traceCellResults('Installing PTVSD', ptvsdInstallResults);
306331
sendTelemetryEvent(Telemetry.PtvsdInstallFailed);
307332
traceError('Failed to install ptvsd');
308333
// Failed to install ptvsd, throw to exit debugging

0 commit comments

Comments
 (0)