Skip to content

Commit d63031c

Browse files
authored
Put debugger data viewer integration behind an experiment (#14460)
1 parent 2971ac5 commit d63031c

File tree

9 files changed

+67
-13
lines changed

9 files changed

+67
-13
lines changed

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"theme": "dark"
2929
},
3030
"engines": {
31-
"vscode": "^1.48.0"
31+
"vscode": "^1.49.0"
3232
},
3333
"keywords": [
3434
"python",
@@ -1670,7 +1670,7 @@
16701670
{
16711671
"command": "python.datascience.showDataViewer",
16721672
"group": "1_view",
1673-
"when": "debugProtocolVariableMenuContext == 'viewableInDataViewer'"
1673+
"when": "python.isDebuggerDataViewerExperimentEnabled && debugProtocolVariableMenuContext == 'viewableInDataViewer'"
16741674
}
16751675
]
16761676
},
@@ -2127,6 +2127,7 @@
21272127
"RunByLine - experiment",
21282128
"tryPylance",
21292129
"jediLSP",
2130+
"debuggerDataViewer",
21302131
"All"
21312132
]
21322133
},
@@ -2152,6 +2153,7 @@
21522153
"RunByLine - experiment",
21532154
"tryPylance",
21542155
"jediLSP",
2156+
"debuggerDataViewer",
21552157
"All"
21562158
]
21572159
},

src/client/common/serviceRegistry.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Licensed under the MIT License.
33
import { IExtensionSingleActivationService } from '../activation/types';
44
import { IExperimentService, IFileDownloader, IHttpClient, IInterpreterPathService } from '../common/types';
5+
import { DebuggerDataViewerExperimentEnabler } from '../datascience/data-viewing/debuggerDataViewerExperimentEnabler';
56
import { LiveShareApi } from '../datascience/liveshare/liveshare';
67
import { INotebookExecutionLogger } from '../datascience/types';
78
import { IServiceManager } from '../ioc/types';
@@ -218,5 +219,9 @@ export function registerTypes(serviceManager: IServiceManager) {
218219
IExtensionSingleActivationService,
219220
DebugSessionTelemetry
220221
);
222+
serviceManager.addSingleton<IExtensionSingleActivationService>(
223+
IExtensionSingleActivationService,
224+
DebuggerDataViewerExperimentEnabler
225+
);
221226
serviceManager.addSingleton<ICustomEditorService>(ICustomEditorService, CustomEditorService);
222227
}

src/client/datascience/commands/commandRegistry.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { IConfigurationService, IDisposable, IOutputChannel } from '../../common
1616
import { DataScience } from '../../common/utils/localize';
1717
import { noop } from '../../common/utils/misc';
1818
import { captureTelemetry, sendTelemetryEvent } from '../../telemetry';
19+
import { EventName } from '../../telemetry/constants';
1920
import { Commands, JUPYTER_OUTPUT_CHANNEL, Telemetry } from '../constants';
2021
import { IDataViewerFactory } from '../data-viewing/types';
2122
import { DataViewerChecker } from '../interactive-common/dataViewerChecker';
@@ -481,7 +482,7 @@ export class CommandRegistry implements IDisposable {
481482
}
482483

483484
private async onVariablePanelShowDataViewerRequest(request: IShowDataViewerFromVariablePanel) {
484-
sendTelemetryEvent(Telemetry.OpenDataViewerFromVariableWindowRequest);
485+
sendTelemetryEvent(EventName.OPEN_DATAVIEWER_FROM_VARIABLE_WINDOW_REQUEST);
485486
if (this.debugService.activeDebugSession) {
486487
const jupyterVariable = convertDebugProtocolVariableToIJupyterVariable(
487488
request.variable as DebugProtocol.Variable
@@ -495,10 +496,10 @@ export class CommandRegistry implements IDisposable {
495496
if (columnSize && (await this.dataViewerChecker.isRequestedColumnSizeAllowed(columnSize))) {
496497
const title: string = `${DataScience.dataExplorerTitle()} - ${jupyterVariable.name}`;
497498
await this.dataViewerFactory.create(jupyterVariableDataProvider, title);
498-
sendTelemetryEvent(Telemetry.OpenDataViewerFromVariableWindowSuccess);
499+
sendTelemetryEvent(EventName.OPEN_DATAVIEWER_FROM_VARIABLE_WINDOW_SUCCESS);
499500
}
500501
} catch (e) {
501-
sendTelemetryEvent(Telemetry.OpenDataViewerFromVariableWindowError);
502+
sendTelemetryEvent(EventName.OPEN_DATAVIEWER_FROM_VARIABLE_WINDOW_ERROR, undefined, e);
502503
traceError(e);
503504
this.appShell.showErrorMessage(e.toString());
504505
}

src/client/datascience/constants.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -410,10 +410,7 @@ export enum Telemetry {
410410
TrustAllNotebooks = 'DATASCIENCE.TRUST_ALL_NOTEBOOKS',
411411
TrustNotebook = 'DATASCIENCE.TRUST_NOTEBOOK',
412412
DoNotTrustNotebook = 'DATASCIENCE.DO_NOT_TRUST_NOTEBOOK',
413-
NotebookTrustPromptShown = 'DATASCIENCE.NOTEBOOK_TRUST_PROMPT_SHOWN',
414-
OpenDataViewerFromVariableWindowRequest = 'DATASCIENCE.OPEN_DATAVIEWER_FROM_VARIABLE_WINDOW_REQUEST',
415-
OpenDataViewerFromVariableWindowError = 'DATASCIENCE.OPEN_DATAVIEWER_FROM_VARIABLE_WINDOW_ERROR',
416-
OpenDataViewerFromVariableWindowSuccess = 'DATASCIENCE.OPEN_DATAVIEWER_FROM_VARIABLE_WINDOW_SUCCESS'
413+
NotebookTrustPromptShown = 'DATASCIENCE.NOTEBOOK_TRUST_PROMPT_SHOWN'
417414
}
418415

419416
export enum NativeKeyboardCommandTelemetry {
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { inject, injectable } from 'inversify';
2+
import { IExtensionSingleActivationService } from '../../activation/types';
3+
import { ICommandManager } from '../../common/application/types';
4+
import { ContextKey } from '../../common/contextKey';
5+
import { traceError } from '../../common/logger';
6+
import { IExperimentService } from '../../common/types';
7+
8+
@injectable()
9+
export class DebuggerDataViewerExperimentEnabler implements IExtensionSingleActivationService {
10+
constructor(
11+
@inject(ICommandManager) private readonly commandManager: ICommandManager,
12+
@inject(IExperimentService) private readonly experimentService: IExperimentService
13+
) {}
14+
public async activate() {
15+
this.activateInternal().catch(traceError.bind('Failed to activate debuggerDataViewerExperimentEnabler'));
16+
}
17+
private async activateInternal() {
18+
// This context key controls the visibility of the 'View Variable in Data Viewer'
19+
// context menu item from the variable window context menu during a debugging session
20+
const isDataViewerExperimentEnabled = new ContextKey(
21+
'python.isDebuggerDataViewerExperimentEnabled',
22+
this.commandManager
23+
);
24+
await isDataViewerExperimentEnabled.set(await this.experimentService.inExperiment('debuggerDataViewer'));
25+
}
26+
}

src/client/datascience/interactive-common/interactiveWindowTypes.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
// Licensed under the MIT License.
33
'use strict';
44
import * as monacoEditor from 'monaco-editor/esm/vs/editor/editor.api';
5-
import { DebugProtocolVariable, DebugProtocolVariableContainer, Uri } from 'vscode';
5+
import { Uri } from 'vscode';
6+
import { DebugProtocolVariable, DebugProtocolVariableContainer } from '../../../../types/vscode-proposed';
67
import { DebugState, IServerState } from '../../../datascience-ui/interactive-common/mainState';
78

89
import type { KernelMessage } from '@jupyterlab/services';

src/client/telemetry/constants.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ export enum EventName {
5555
DEBUGGER_ATTACH_TO_LOCAL_PROCESS = 'DEBUGGER.ATTACH_TO_LOCAL_PROCESS',
5656
DEBUGGER_CONFIGURATION_PROMPTS = 'DEBUGGER.CONFIGURATION.PROMPTS',
5757
DEBUGGER_CONFIGURATION_PROMPTS_IN_LAUNCH_JSON = 'DEBUGGER.CONFIGURATION.PROMPTS.IN.LAUNCH.JSON',
58+
OPEN_DATAVIEWER_FROM_VARIABLE_WINDOW_REQUEST = 'OPEN_DATAVIEWER_FROM_VARIABLE_WINDOW_REQUEST',
59+
OPEN_DATAVIEWER_FROM_VARIABLE_WINDOW_ERROR = 'OPEN_DATAVIEWER_FROM_VARIABLE_WINDOW_ERROR',
60+
OPEN_DATAVIEWER_FROM_VARIABLE_WINDOW_SUCCESS = 'OPEN_DATAVIEWER_FROM_VARIABLE_WINDOW_SUCCESS',
5861
UNITTEST_STOP = 'UNITTEST.STOP',
5962
UNITTEST_DISABLE = 'UNITTEST.DISABLE',
6063
UNITTEST_RUN = 'UNITTEST.RUN',

src/client/telemetry/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,9 @@ export interface IEventNamePropertyMapping {
587587
*/
588588
manuallyEnteredAValue?: boolean;
589589
};
590+
[EventName.OPEN_DATAVIEWER_FROM_VARIABLE_WINDOW_REQUEST]: never | undefined;
591+
[EventName.OPEN_DATAVIEWER_FROM_VARIABLE_WINDOW_ERROR]: never | undefined;
592+
[EventName.OPEN_DATAVIEWER_FROM_VARIABLE_WINDOW_SUCCESS]: never | undefined;
590593
/**
591594
* Telemetry event sent when providing completion provider in launch.json. It is sent just *after* inserting the completion.
592595
*/
@@ -1772,9 +1775,6 @@ export interface IEventNamePropertyMapping {
17721775
[Telemetry.SetJupyterURIToUserSpecified]: never | undefined;
17731776
[Telemetry.ShiftEnterBannerShown]: never | undefined;
17741777
[Telemetry.ShowDataViewer]: { rows: number | undefined; columns: number | undefined };
1775-
[Telemetry.OpenDataViewerFromVariableWindowRequest]: never | undefined;
1776-
[Telemetry.OpenDataViewerFromVariableWindowError]: never | undefined;
1777-
[Telemetry.OpenDataViewerFromVariableWindowSuccess]: never | undefined;
17781778
[Telemetry.CreateNewInteractive]: never | undefined;
17791779
[Telemetry.StartJupyter]: never | undefined;
17801780
[Telemetry.StartJupyterProcess]: never | undefined;

types/vscode-proposed/index.d.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -730,3 +730,22 @@ export namespace notebook {
730730
priority?: number
731731
): NotebookCellStatusBarItem;
732732
}
733+
734+
//#region debug
735+
736+
/**
737+
* A DebugProtocolVariableContainer is an opaque stand-in type for the intersection of the Scope and Variable types defined in the Debug Adapter Protocol.
738+
* See https://microsoft.github.io/debug-adapter-protocol/specification#Types_Scope and https://microsoft.github.io/debug-adapter-protocol/specification#Types_Variable.
739+
*/
740+
export interface DebugProtocolVariableContainer {
741+
// Properties: the intersection of DAP's Scope and Variable types.
742+
}
743+
744+
/**
745+
* A DebugProtocolVariable is an opaque stand-in type for the Variable type defined in the Debug Adapter Protocol.
746+
* See https://microsoft.github.io/debug-adapter-protocol/specification#Types_Variable.
747+
*/
748+
export interface DebugProtocolVariable {
749+
// Properties: see details [here](https://microsoft.github.io/debug-adapter-protocol/specification#Base_Protocol_Variable).
750+
}
751+
//#endregion

0 commit comments

Comments
 (0)