GeezerVison is showing github.com — Ensure wheels experiment control and experiment groups uses right whe… · xytnba/pythonVSCode@8874744
File treeExpand file treeCollapse file tree Open diff view settings debugger/extension/adapter
test/debugger/extension/adapter
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: build/ci/templates/steps/build.yml +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 22 | 22 | python -m pip install -U pip | 23 | 23 | python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python --no-cache-dir --implementation py --no-deps --upgrade -r requirements.txt | 24 | 24 | python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python/old_ptvsd --no-cache-dir --implementation py --no-deps --upgrade 'ptvsd==4.3.2' | | 25 | + python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python/new_ptvsd/no_wheels --no-cache-dir --implementation py --no-deps --upgrade 'ptvsd==5.0.0a7' | 25 | 26 | failOnStderr: true | 26 | 27 | displayName: "pip install requirements" | 27 | 28 |
| |
Collapse file Copy file name to clipboardExpand all lines: build/ci/templates/test_phases.yml +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 96 | 96 | python -m pip install --upgrade -r build/test-requirements.txt | 97 | 97 | python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python --no-cache-dir --implementation py --no-deps --upgrade -r requirements.txt | 98 | 98 | python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python/old_ptvsd --no-cache-dir --implementation py --no-deps --upgrade 'ptvsd==4.3.2' | | 99 | + python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python/new_ptvsd/no_wheels --no-cache-dir --implementation py --no-deps --upgrade 'ptvsd==5.0.0a7' | 99 | 100 | displayName: 'pip install system test requirements' | 100 | 101 | condition: and(succeeded(), eq(variables['NeedsPythonTestReqs'], 'true')) | 101 | 102 |
| |
Collapse file Copy file name to clipboardExpand all lines: pythonFiles/install_ptvsd.py +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 6 | 6 |
| 7 | 7 |
| 8 | 8 | EXTENSION_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | 9 | | -DEBUGGER_DEST = os.path.join(EXTENSION_ROOT, "pythonFiles", "lib", "python") | | 9 | +DEBUGGER_DEST = os.path.join(EXTENSION_ROOT, "pythonFiles", "lib", "python", "new_ptvsd", "wheels") | 10 | 10 | DEBUGGER_PACKAGE = "ptvsd" | 11 | 11 | DEBUGGER_VERSION = "5.0.0a7" | 12 | 12 | DEBUGGER_PYTHON_VERSIONS = ("cp37",) | |
Collapse file Copy file name to clipboardExpand all lines: src/client/datascience/jupyter/jupyterDebugger.ts +26-24Lines changed: 26 additions & 24 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -17,16 +17,7 @@ import { EXTENSION_ROOT_DIR } from '../../constants'; | 17 | 17 | import { captureTelemetry, sendTelemetryEvent } from '../../telemetry'; | 18 | 18 | import { concatMultilineStringOutput } from '../common'; | 19 | 19 | import { Identifiers, Telemetry } from '../constants'; | 20 | | -import { | 21 | | - CellState, | 22 | | - ICell, | 23 | | - ICellHashListener, | 24 | | - IConnection, | 25 | | - IFileHashes, | 26 | | - IJupyterDebugger, | 27 | | - INotebook, | 28 | | - ISourceMapRequest | 29 | | -} from '../types'; | | 20 | +import { CellState, ICell, ICellHashListener, IConnection, IFileHashes, IJupyterDebugger, INotebook, ISourceMapRequest } from '../types'; | 30 | 21 | import { JupyterDebuggerNotInstalledError } from './jupyterDebuggerNotInstalledError'; | 31 | 22 | import { JupyterDebuggerRemoteNotSupported } from './jupyterDebuggerRemoteNotSupported'; | 32 | 23 | import { ILiveShareHasRole } from './liveshare/types'; | @@ -45,8 +36,7 @@ export class JupyterDebugger implements IJupyterDebugger, ICellHashListener { | 45 | 36 | @inject(IPlatformService) private platform: IPlatformService, | 46 | 37 | @inject(IWorkspaceService) private workspace: IWorkspaceService, | 47 | 38 | @inject(IExperimentsManager) private readonly experimentsManager: IExperimentsManager | 48 | | - ) { | 49 | | - } | | 39 | + ) {} | 50 | 40 |
| 51 | 41 | public async startDebugging(notebook: INotebook): Promise<void> { | 52 | 42 | traceInfo('start debugging'); | @@ -114,9 +104,11 @@ export class JupyterDebugger implements IJupyterDebugger, ICellHashListener { | 114 | 104 | public async hashesUpdated(hashes: IFileHashes[]): Promise<void> { | 115 | 105 | // Make sure that we have an active debugging session at this point | 116 | 106 | if (this.debugService.activeDebugSession) { | 117 | | - await Promise.all(hashes.map((fileHash) => { | 118 | | - return this.debugService.activeDebugSession!.customRequest('setPydevdSourceMap', this.buildSourceMap(fileHash)); | 119 | | - })); | | 107 | + await Promise.all( | | 108 | + hashes.map(fileHash => { | | 109 | + return this.debugService.activeDebugSession!.customRequest('setPydevdSourceMap', this.buildSourceMap(fileHash)); | | 110 | + }) | | 111 | + ); | 120 | 112 | } | 121 | 113 | } | 122 | 114 |
| @@ -184,18 +176,19 @@ export class JupyterDebugger implements IJupyterDebugger, ICellHashListener { | 184 | 176 | */ | 185 | 177 | private async getPtvsdPath(notebook: INotebook): Promise<string> { | 186 | 178 | const oldPtvsd = path.join(EXTENSION_ROOT_DIR, 'pythonFiles', 'lib', 'python', 'old_ptvsd'); | 187 | | - if (!this.experimentsManager.inExperiment(DebugAdapterDescriptorFactory.experiment) || | 188 | | - !this.experimentsManager.inExperiment(DebugAdapterNewPtvsd.experiment)){ | | 179 | + if (!this.experimentsManager.inExperiment(DebugAdapterDescriptorFactory.experiment) || !this.experimentsManager.inExperiment(DebugAdapterNewPtvsd.experiment)) { | 189 | 180 | return oldPtvsd; | 190 | 181 | } | 191 | 182 | const pythonVersion = await this.getKernelPythonVersion(notebook); | 192 | | - // The new debug adapter is only supported in 3.7 | | 183 | + // The new debug adapter with wheels is only supported in 3.7 | 193 | 184 | // Code can be found here (src/client/debugger/extension/adapter/factory.ts). | 194 | | - if (!pythonVersion || pythonVersion.major < 3 || pythonVersion.minor < 7){ | 195 | | - return oldPtvsd; | | 185 | + if (pythonVersion && pythonVersion.major === 3 && pythonVersion.minor === 7) { | | 186 | + // Return debugger with wheels | | 187 | + return path.join(EXTENSION_ROOT_DIR, 'pythonFiles', 'lib', 'python', 'new_ptvsd', 'wheels'); | 196 | 188 | } | 197 | 189 |
| 198 | | - return path.join(EXTENSION_ROOT_DIR, 'pythonFiles', 'lib', 'python'); | | 190 | + // We are here so this is NOT python 3.7, return debugger without wheels | | 191 | + return path.join(EXTENSION_ROOT_DIR, 'pythonFiles', 'lib', 'python', 'new_ptvsd', 'no_wheels'); | 199 | 192 | } | 200 | 193 | private async calculatePtvsdPathList(notebook: INotebook): Promise<string | undefined> { | 201 | 194 | const extraPaths: string[] = []; | @@ -311,7 +304,12 @@ export class JupyterDebugger implements IJupyterDebugger, ICellHashListener { | 311 | 304 | const minor = parseInt(packageVersionMatch[2], 10); | 312 | 305 | const patch = parseInt(packageVersionMatch[3], 10); | 313 | 306 | return { | 314 | | - major, minor, patch, build: [], prerelease: [], raw: `${major}.${minor}.${patch}` | | 307 | + major, | | 308 | + minor, | | 309 | + patch, | | 310 | + build: [], | | 311 | + prerelease: [], | | 312 | + raw: `${major}.${minor}.${patch}` | 315 | 313 | }; | 316 | 314 | } | 317 | 315 | } | @@ -335,7 +333,11 @@ export class JupyterDebugger implements IJupyterDebugger, ICellHashListener { | 335 | 333 | @captureTelemetry(Telemetry.PtvsdPromptToInstall) | 336 | 334 | private async promptToInstallPtvsd(notebook: INotebook, oldVersion: Version | undefined): Promise<void> { | 337 | 335 | const promptMessage = oldVersion ? localize.DataScience.jupyterDebuggerInstallPtvsdUpdate() : localize.DataScience.jupyterDebuggerInstallPtvsdNew(); | 338 | | - const result = await this.appShell.showInformationMessage(promptMessage, localize.DataScience.jupyterDebuggerInstallPtvsdYes(), localize.DataScience.jupyterDebuggerInstallPtvsdNo()); | | 336 | + const result = await this.appShell.showInformationMessage( | | 337 | + promptMessage, | | 338 | + localize.DataScience.jupyterDebuggerInstallPtvsdYes(), | | 339 | + localize.DataScience.jupyterDebuggerInstallPtvsdNo() | | 340 | + ); | 339 | 341 |
| 340 | 342 | if (result === localize.DataScience.jupyterDebuggerInstallPtvsdYes()) { | 341 | 343 | await this.installPtvsd(notebook); | @@ -424,7 +426,7 @@ export class JupyterDebugger implements IJupyterDebugger, ICellHashListener { | 424 | 426 | const data = outputs[0].data; | 425 | 427 | if (data && data.hasOwnProperty('text/plain')) { | 426 | 428 | // tslint:disable-next-line:no-any | 427 | | - return ((data as any)['text/plain']); | | 429 | + return (data as any)['text/plain']; | 428 | 430 | } | 429 | 431 | if (outputs[0].output_type === 'stream') { | 430 | 432 | const stream = outputs[0] as nbformat.IStream; | |
Collapse file Copy file name to clipboardExpand all lines: src/client/debugger/extension/adapter/factory.ts +15-7Lines changed: 15 additions & 7 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -12,6 +12,8 @@ import { traceVerbose } from '../../../common/logger'; | 12 | 12 | import { IExperimentsManager } from '../../../common/types'; | 13 | 13 | import { EXTENSION_ROOT_DIR } from '../../../constants'; | 14 | 14 | import { IInterpreterService } from '../../../interpreter/contracts'; | | 15 | +import { sendTelemetryEvent } from '../../../telemetry'; | | 16 | +import { EventName } from '../../../telemetry/constants'; | 15 | 17 | import { RemoteDebugOptions } from '../../debugAdapter/types'; | 16 | 18 | import { AttachRequestArguments, LaunchRequestArguments } from '../../types'; | 17 | 19 | import { IDebugAdapterDescriptorFactory } from '../types'; | @@ -24,7 +26,7 @@ export class DebugAdapterDescriptorFactory implements IDebugAdapterDescriptorFac | 24 | 26 | @inject(IInterpreterService) private readonly interpreterService: IInterpreterService, | 25 | 27 | @inject(IApplicationShell) private readonly appShell: IApplicationShell, | 26 | 28 | @inject(IExperimentsManager) private readonly experimentsManager: IExperimentsManager | 27 | | - ) { } | | 29 | + ) {} | 28 | 30 | public async createDebugAdapterDescriptor(session: DebugSession, executable: DebugAdapterExecutable | undefined): Promise<DebugAdapterDescriptor> { | 29 | 31 | const configuration = session.configuration as (LaunchRequestArguments | AttachRequestArguments); | 30 | 32 |
| @@ -37,11 +39,17 @@ export class DebugAdapterDescriptorFactory implements IDebugAdapterDescriptorFac | 37 | 39 | return new DebugAdapterServer(port, configuration.host); | 38 | 40 | } else { | 39 | 41 | const pythonPath = await this.getPythonPath(configuration, session.workspaceFolder); | 40 | | - if (await this.useNewPtvsd(pythonPath)) { | 41 | | - // If logToFile is set in the debug config then pass --log-dir <path-to-extension-dir> when launching the debug adapter. | 42 | | - const logArgs = configuration.logToFile ? ['--log-dir', EXTENSION_ROOT_DIR] : []; | 43 | | - const ptvsdPathToUse = this.getPtvsdPath(); | 44 | | - return new DebugAdapterExecutable(pythonPath, [path.join(ptvsdPathToUse, 'adapter'), ...logArgs]); | | 42 | + // If logToFile is set in the debug config then pass --log-dir <path-to-extension-dir> when launching the debug adapter. | | 43 | + const logArgs = configuration.logToFile ? ['--log-dir', EXTENSION_ROOT_DIR] : []; | | 44 | + const ptvsdPathToUse = path.join(EXTENSION_ROOT_DIR, 'pythonFiles', 'lib', 'python', 'new_ptvsd'); | | 45 | + if (pythonPath.length !== 0) { | | 46 | + if (await this.useNewPtvsd(pythonPath)) { | | 47 | + sendTelemetryEvent(EventName.DEBUG_ADAPTER_USING_WHEELS_PATH, undefined, { usingWheels: true }); | | 48 | + return new DebugAdapterExecutable(pythonPath, [path.join(ptvsdPathToUse, 'wheels', 'ptvsd', 'adapter'), ...logArgs]); | | 49 | + } else { | | 50 | + sendTelemetryEvent(EventName.DEBUG_ADAPTER_USING_WHEELS_PATH, undefined, { usingWheels: false }); | | 51 | + return new DebugAdapterExecutable(pythonPath, [path.join(ptvsdPathToUse, 'no_wheels', 'ptvsd', 'adapter'), ...logArgs]); | | 52 | + } | 45 | 53 | } | 46 | 54 | } | 47 | 55 | } else { | @@ -73,7 +81,7 @@ export class DebugAdapterDescriptorFactory implements IDebugAdapterDescriptorFac | 73 | 81 | } | 74 | 82 |
| 75 | 83 | public getPtvsdPath(): string { | 76 | | - return path.join(EXTENSION_ROOT_DIR, 'pythonFiles', 'lib', 'python', 'ptvsd'); | | 84 | + return path.join(EXTENSION_ROOT_DIR, 'pythonFiles', 'lib', 'python', 'new_ptvsd', 'no_wheels', 'ptvsd'); | 77 | 85 | } | 78 | 86 |
| 79 | 87 | public getRemotePtvsdArgs(remoteDebugOptions: RemoteDebugOptions): string[] { | |
Collapse file Copy file name to clipboardExpand all lines: src/client/telemetry/constants.ts +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -39,6 +39,7 @@ export enum EventName { | 39 | 39 | WORKSPACE_SYMBOLS_GO_TO = 'WORKSPACE_SYMBOLS.GO_TO', | 40 | 40 | EXECUTION_CODE = 'EXECUTION_CODE', | 41 | 41 | EXECUTION_DJANGO = 'EXECUTION_DJANGO', | | 42 | + DEBUG_ADAPTER_USING_WHEELS_PATH = 'DEBUG_ADAPTER.USING_WHEELS_PATH', | 42 | 43 | DEBUG_SESSION_ERROR = 'DEBUG_SESSION.ERROR', | 43 | 44 | DEBUG_SESSION_START = 'DEBUG_SESSION.START', | 44 | 45 | DEBUG_SESSION_STOP = 'DEBUG_SESSION.STOP', | |
Collapse file Copy file name to clipboardExpand all lines: src/client/telemetry/index.ts +11Lines changed: 11 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -264,6 +264,17 @@ export interface IEventNamePropertyMapping { | 264 | 264 | */ | 265 | 265 | enabled: boolean; | 266 | 266 | }; | | 267 | + /** | | 268 | + * Telemetry event captured when debug adapter executable is created | | 269 | + */ | | 270 | + [EventName.DEBUG_ADAPTER_USING_WHEELS_PATH]: { | | 271 | + /** | | 272 | + * Carries boolean | | 273 | + * - `true` if path used for the adapter is the debugger with wheels. | | 274 | + * - `false` if path used for the adapter is the source only version of the debugger. | | 275 | + */ | | 276 | + usingWheels: boolean; | | 277 | + }; | 267 | 278 | /** | 268 | 279 | * Telemetry captured before starting debug session. | 269 | 280 | */ | |
|