diff --git a/build/ci/vscode-python-nightly-flake-ci.yaml b/build/ci/vscode-python-nightly-flake-ci.yaml index c61e3b35e2a3..1a82a5bcd1cd 100644 --- a/build/ci/vscode-python-nightly-flake-ci.yaml +++ b/build/ci/vscode-python-nightly-flake-ci.yaml @@ -29,6 +29,7 @@ variables: 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. MOCHA_REPORTER_JUNIT: true # Use the mocha-multi-reporters and send output to both console (spec) and JUnit (mocha-junit-reporter). VSC_PYTHON_LOG_FILE: '$(Build.ArtifactStagingDirectory)/pvsc.log' + PTVSD_LOG_DIR: '$(Build.ArtifactStagingDirectory)' # Get the debugger to log output too jobs: diff --git a/src/client/datascience/jupyter/jupyterDebugger.ts b/src/client/datascience/jupyter/jupyterDebugger.ts index e0524275afa1..e6538cf731d5 100644 --- a/src/client/datascience/jupyter/jupyterDebugger.ts +++ b/src/client/datascience/jupyter/jupyterDebugger.ts @@ -57,6 +57,8 @@ export class JupyterDebugger implements IJupyterDebugger, ICellHashListener { // Try to connect to this notebook const config = await this.connect(notebook); if (config) { + traceInfo('connected to notebook during debugging'); + // First check if this is a live share session. Skip debugging attach on the guest // tslint:disable-next-line: no-any const hasRole = (notebook as any) as ILiveShareHasRole; @@ -75,6 +77,8 @@ export class JupyterDebugger implements IJupyterDebugger, ICellHashListener { const importResults = await this.executeSilently(notebook, `import ptvsd\nptvsd.wait_for_attach()`); if (importResults.length === 0 || importResults[0].state === CellState.error) { traceWarning('PTVSD not found in path.'); + } else { + this.traceCellResults('import startup', importResults); } // Then enable tracing @@ -119,6 +123,22 @@ export class JupyterDebugger implements IJupyterDebugger, ICellHashListener { } } + private traceCellResults(prefix: string, results: ICell[]) { + if (results.length > 0 && results[0].data.cell_type === 'code') { + const cell = results[0].data as nbformat.ICodeCell; + const error = cell.outputs[0].evalue; + if (error) { + traceError(`${prefix} Error : ${error}`); + } else { + const data = cell.outputs[0].data; + const text = cell.outputs[0].text; + traceInfo(`${prefix} Output: ${text || JSON.stringify(data)}`); + } + } else { + traceInfo(`${prefix} no output.`); + } + } + private async connect(notebook: INotebook): Promise { // If we already have configuration, we're already attached, don't do it again. let result = this.configs.get(notebook.resource.toString()); @@ -201,7 +221,8 @@ export class JupyterDebugger implements IJupyterDebugger, ICellHashListener { const ptvsdPathList = this.calculatePtvsdPathList(notebook); if (ptvsdPathList && ptvsdPathList.length > 0) { - await this.executeSilently(notebook, `import sys\r\nsys.path.extend([${ptvsdPathList}])\r\nsys.path`); + const result = await this.executeSilently(notebook, `import sys\r\nsys.path.extend([${ptvsdPathList}])\r\nsys.path`); + this.traceCellResults('Appending paths', result); } } @@ -243,6 +264,7 @@ export class JupyterDebugger implements IJupyterDebugger, ICellHashListener { private parsePtvsdVersionInfo(cells: ICell[]): IPtvsdVersion | undefined { if (cells.length < 1 || cells[0].state !== CellState.finished) { + this.traceCellResults('parsePtvsdVersionInfo', cells); return undefined; } @@ -262,6 +284,8 @@ export class JupyterDebugger implements IJupyterDebugger, ICellHashListener { } } + this.traceCellResults('parsingPtvsdVersionInfo', cells); + return undefined; } @@ -292,6 +316,7 @@ export class JupyterDebugger implements IJupyterDebugger, ICellHashListener { private async installPtvsd(notebook: INotebook): Promise { // tslint:disable-next-line:no-multiline-string const ptvsdInstallResults = await this.executeSilently(notebook, `import sys\r\n!{sys.executable} -m pip install -U ptvsd`); + traceInfo('Installing ptvsd'); if (ptvsdInstallResults.length > 0) { const installResultsString = this.extractOutput(ptvsdInstallResults[0]); @@ -302,7 +327,7 @@ export class JupyterDebugger implements IJupyterDebugger, ICellHashListener { return; } } - + this.traceCellResults('Installing PTVSD', ptvsdInstallResults); sendTelemetryEvent(Telemetry.PtvsdInstallFailed); traceError('Failed to install ptvsd'); // Failed to install ptvsd, throw to exit debugging