Skip to content

Ensure wheels experiment control and experiment groups uses right wheel #8461

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build/ci/templates/steps/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ steps:
python -m pip install -U pip
python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python --no-cache-dir --implementation py --no-deps --upgrade -r requirements.txt
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'
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'
failOnStderr: true
displayName: "pip install requirements"

Expand Down
1 change: 1 addition & 0 deletions build/ci/templates/test_phases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ steps:
python -m pip install --upgrade -r build/test-requirements.txt
python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python --no-cache-dir --implementation py --no-deps --upgrade -r requirements.txt
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'
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'
displayName: 'pip install system test requirements'
condition: and(succeeded(), eq(variables['NeedsPythonTestReqs'], 'true'))

Expand Down
2 changes: 1 addition & 1 deletion pythonFiles/install_ptvsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


EXTENSION_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
DEBUGGER_DEST = os.path.join(EXTENSION_ROOT, "pythonFiles", "lib", "python")
DEBUGGER_DEST = os.path.join(EXTENSION_ROOT, "pythonFiles", "lib", "python", "new_ptvsd", "wheels")
DEBUGGER_PACKAGE = "ptvsd"
DEBUGGER_VERSION = "5.0.0a7"
DEBUGGER_PYTHON_VERSIONS = ("cp37",)
Expand Down
50 changes: 26 additions & 24 deletions src/client/datascience/jupyter/jupyterDebugger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,7 @@ import { EXTENSION_ROOT_DIR } from '../../constants';
import { captureTelemetry, sendTelemetryEvent } from '../../telemetry';
import { concatMultilineStringOutput } from '../common';
import { Identifiers, Telemetry } from '../constants';
import {
CellState,
ICell,
ICellHashListener,
IConnection,
IFileHashes,
IJupyterDebugger,
INotebook,
ISourceMapRequest
} from '../types';
import { CellState, ICell, ICellHashListener, IConnection, IFileHashes, IJupyterDebugger, INotebook, ISourceMapRequest } from '../types';
import { JupyterDebuggerNotInstalledError } from './jupyterDebuggerNotInstalledError';
import { JupyterDebuggerRemoteNotSupported } from './jupyterDebuggerRemoteNotSupported';
import { ILiveShareHasRole } from './liveshare/types';
Expand All @@ -45,8 +36,7 @@ export class JupyterDebugger implements IJupyterDebugger, ICellHashListener {
@inject(IPlatformService) private platform: IPlatformService,
@inject(IWorkspaceService) private workspace: IWorkspaceService,
@inject(IExperimentsManager) private readonly experimentsManager: IExperimentsManager
) {
}
) {}

public async startDebugging(notebook: INotebook): Promise<void> {
traceInfo('start debugging');
Expand Down Expand Up @@ -114,9 +104,11 @@ export class JupyterDebugger implements IJupyterDebugger, ICellHashListener {
public async hashesUpdated(hashes: IFileHashes[]): Promise<void> {
// Make sure that we have an active debugging session at this point
if (this.debugService.activeDebugSession) {
await Promise.all(hashes.map((fileHash) => {
return this.debugService.activeDebugSession!.customRequest('setPydevdSourceMap', this.buildSourceMap(fileHash));
}));
await Promise.all(
hashes.map(fileHash => {
return this.debugService.activeDebugSession!.customRequest('setPydevdSourceMap', this.buildSourceMap(fileHash));
})
);
}
}

Expand Down Expand Up @@ -184,18 +176,19 @@ export class JupyterDebugger implements IJupyterDebugger, ICellHashListener {
*/
private async getPtvsdPath(notebook: INotebook): Promise<string> {
const oldPtvsd = path.join(EXTENSION_ROOT_DIR, 'pythonFiles', 'lib', 'python', 'old_ptvsd');
if (!this.experimentsManager.inExperiment(DebugAdapterDescriptorFactory.experiment) ||
!this.experimentsManager.inExperiment(DebugAdapterNewPtvsd.experiment)){
if (!this.experimentsManager.inExperiment(DebugAdapterDescriptorFactory.experiment) || !this.experimentsManager.inExperiment(DebugAdapterNewPtvsd.experiment)) {
return oldPtvsd;
}
const pythonVersion = await this.getKernelPythonVersion(notebook);
// The new debug adapter is only supported in 3.7
// The new debug adapter with wheels is only supported in 3.7
// Code can be found here (src/client/debugger/extension/adapter/factory.ts).
if (!pythonVersion || pythonVersion.major < 3 || pythonVersion.minor < 7){
return oldPtvsd;
if (pythonVersion && pythonVersion.major === 3 && pythonVersion.minor === 7) {
// Return debugger with wheels
return path.join(EXTENSION_ROOT_DIR, 'pythonFiles', 'lib', 'python', 'new_ptvsd', 'wheels');
}

return path.join(EXTENSION_ROOT_DIR, 'pythonFiles', 'lib', 'python');
// We are here so this is NOT python 3.7, return debugger without wheels
return path.join(EXTENSION_ROOT_DIR, 'pythonFiles', 'lib', 'python', 'new_ptvsd', 'no_wheels');
}
private async calculatePtvsdPathList(notebook: INotebook): Promise<string | undefined> {
const extraPaths: string[] = [];
Expand Down Expand Up @@ -311,7 +304,12 @@ export class JupyterDebugger implements IJupyterDebugger, ICellHashListener {
const minor = parseInt(packageVersionMatch[2], 10);
const patch = parseInt(packageVersionMatch[3], 10);
return {
major, minor, patch, build: [], prerelease: [], raw: `${major}.${minor}.${patch}`
major,
minor,
patch,
build: [],
prerelease: [],
raw: `${major}.${minor}.${patch}`
};
}
}
Expand All @@ -335,7 +333,11 @@ export class JupyterDebugger implements IJupyterDebugger, ICellHashListener {
@captureTelemetry(Telemetry.PtvsdPromptToInstall)
private async promptToInstallPtvsd(notebook: INotebook, oldVersion: Version | undefined): Promise<void> {
const promptMessage = oldVersion ? localize.DataScience.jupyterDebuggerInstallPtvsdUpdate() : localize.DataScience.jupyterDebuggerInstallPtvsdNew();
const result = await this.appShell.showInformationMessage(promptMessage, localize.DataScience.jupyterDebuggerInstallPtvsdYes(), localize.DataScience.jupyterDebuggerInstallPtvsdNo());
const result = await this.appShell.showInformationMessage(
promptMessage,
localize.DataScience.jupyterDebuggerInstallPtvsdYes(),
localize.DataScience.jupyterDebuggerInstallPtvsdNo()
);

if (result === localize.DataScience.jupyterDebuggerInstallPtvsdYes()) {
await this.installPtvsd(notebook);
Expand Down Expand Up @@ -424,7 +426,7 @@ export class JupyterDebugger implements IJupyterDebugger, ICellHashListener {
const data = outputs[0].data;
if (data && data.hasOwnProperty('text/plain')) {
// tslint:disable-next-line:no-any
return ((data as any)['text/plain']);
return (data as any)['text/plain'];
}
if (outputs[0].output_type === 'stream') {
const stream = outputs[0] as nbformat.IStream;
Expand Down
22 changes: 15 additions & 7 deletions src/client/debugger/extension/adapter/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import { traceVerbose } from '../../../common/logger';
import { IExperimentsManager } from '../../../common/types';
import { EXTENSION_ROOT_DIR } from '../../../constants';
import { IInterpreterService } from '../../../interpreter/contracts';
import { sendTelemetryEvent } from '../../../telemetry';
import { EventName } from '../../../telemetry/constants';
import { RemoteDebugOptions } from '../../debugAdapter/types';
import { AttachRequestArguments, LaunchRequestArguments } from '../../types';
import { IDebugAdapterDescriptorFactory } from '../types';
Expand All @@ -24,7 +26,7 @@ export class DebugAdapterDescriptorFactory implements IDebugAdapterDescriptorFac
@inject(IInterpreterService) private readonly interpreterService: IInterpreterService,
@inject(IApplicationShell) private readonly appShell: IApplicationShell,
@inject(IExperimentsManager) private readonly experimentsManager: IExperimentsManager
) { }
) {}
public async createDebugAdapterDescriptor(session: DebugSession, executable: DebugAdapterExecutable | undefined): Promise<DebugAdapterDescriptor> {
const configuration = session.configuration as (LaunchRequestArguments | AttachRequestArguments);

Expand All @@ -37,11 +39,17 @@ export class DebugAdapterDescriptorFactory implements IDebugAdapterDescriptorFac
return new DebugAdapterServer(port, configuration.host);
} else {
const pythonPath = await this.getPythonPath(configuration, session.workspaceFolder);
if (await this.useNewPtvsd(pythonPath)) {
// If logToFile is set in the debug config then pass --log-dir <path-to-extension-dir> when launching the debug adapter.
const logArgs = configuration.logToFile ? ['--log-dir', EXTENSION_ROOT_DIR] : [];
const ptvsdPathToUse = this.getPtvsdPath();
return new DebugAdapterExecutable(pythonPath, [path.join(ptvsdPathToUse, 'adapter'), ...logArgs]);
// If logToFile is set in the debug config then pass --log-dir <path-to-extension-dir> when launching the debug adapter.
const logArgs = configuration.logToFile ? ['--log-dir', EXTENSION_ROOT_DIR] : [];
const ptvsdPathToUse = path.join(EXTENSION_ROOT_DIR, 'pythonFiles', 'lib', 'python', 'new_ptvsd');
if (pythonPath.length !== 0) {
if (await this.useNewPtvsd(pythonPath)) {
sendTelemetryEvent(EventName.DEBUG_ADAPTER_USING_WHEELS_PATH, undefined, { usingWheels: true });
return new DebugAdapterExecutable(pythonPath, [path.join(ptvsdPathToUse, 'wheels', 'ptvsd', 'adapter'), ...logArgs]);
} else {
sendTelemetryEvent(EventName.DEBUG_ADAPTER_USING_WHEELS_PATH, undefined, { usingWheels: false });
return new DebugAdapterExecutable(pythonPath, [path.join(ptvsdPathToUse, 'no_wheels', 'ptvsd', 'adapter'), ...logArgs]);
}
}
}
} else {
Expand Down Expand Up @@ -73,7 +81,7 @@ export class DebugAdapterDescriptorFactory implements IDebugAdapterDescriptorFac
}

public getPtvsdPath(): string {
return path.join(EXTENSION_ROOT_DIR, 'pythonFiles', 'lib', 'python', 'ptvsd');
return path.join(EXTENSION_ROOT_DIR, 'pythonFiles', 'lib', 'python', 'new_ptvsd', 'no_wheels', 'ptvsd');
}

public getRemotePtvsdArgs(remoteDebugOptions: RemoteDebugOptions): string[] {
Expand Down
1 change: 1 addition & 0 deletions src/client/telemetry/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export enum EventName {
WORKSPACE_SYMBOLS_GO_TO = 'WORKSPACE_SYMBOLS.GO_TO',
EXECUTION_CODE = 'EXECUTION_CODE',
EXECUTION_DJANGO = 'EXECUTION_DJANGO',
DEBUG_ADAPTER_USING_WHEELS_PATH = 'DEBUG_ADAPTER.USING_WHEELS_PATH',
DEBUG_SESSION_ERROR = 'DEBUG_SESSION.ERROR',
DEBUG_SESSION_START = 'DEBUG_SESSION.START',
DEBUG_SESSION_STOP = 'DEBUG_SESSION.STOP',
Expand Down
11 changes: 11 additions & 0 deletions src/client/telemetry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,17 @@ export interface IEventNamePropertyMapping {
*/
enabled: boolean;
};
/**
* Telemetry event captured when debug adapter executable is created
*/
[EventName.DEBUG_ADAPTER_USING_WHEELS_PATH]: {
/**
* Carries boolean
* - `true` if path used for the adapter is the debugger with wheels.
* - `false` if path used for the adapter is the source only version of the debugger.
*/
usingWheels: boolean;
};
/**
* Telemetry captured before starting debug session.
*/
Expand Down
Loading