Skip to content

Commit

Permalink
variable window in rbl (#6752)
Browse files Browse the repository at this point in the history
* remove can debug flag
and catch stackTrace response when running by line

* use debugger variables in the debugging manager

* send refresh variables message

* oops

* lint

* lint

* try to get variable view to refresh

* finally

* lint

* lint

* lint

* register the tracker on
debuggerVariableRegistration

* lint

* remove breakpoint margin code

* add event to debuggingManager

* send message direclty from debuggingManager to
variableView

* don't send variables in the event

* pr comments

* woohoo

* Rich's comment

* add comments

* oops

* oops

* lint

* remove parameter

* pass cell index in the config directly

* replace localized variable with constant

* lint

* open variable view when we start run by line

* remove trackers
  • Loading branch information
David Kutugata authored Aug 10, 2021
1 parent 67a9482 commit 8e06fe9
Show file tree
Hide file tree
Showing 14 changed files with 148 additions and 98 deletions.
4 changes: 0 additions & 4 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ module.exports = {
'src/test/datascience/mockJupyterRequest.ts',
'src/test/datascience/jupyterHelpers.ts',
'src/test/datascience/mockJupyterManagerFactory.ts',
'src/test/datascience/mockDebugService.ts',
'src/test/datascience/datascience.unit.test.ts',
'src/test/datascience/kernelFinder.unit.test.ts',
'src/test/datascience/editor-integration/helpers.ts',
Expand Down Expand Up @@ -641,7 +640,6 @@ module.exports = {
'src/client/debugger/extension/attachQuickPick/provider.ts',
'src/client/debugger/extension/attachQuickPick/picker.ts',
'src/client/debugger/extension/helpers/protocolParser.ts',
'src/client/debugger/constants.ts',
'src/client/languageServices/jediProxyFactory.ts',
'src/client/languageServices/proposeLanguageServerBanner.ts',
'src/client/telemetry/types.ts',
Expand Down Expand Up @@ -705,7 +703,6 @@ module.exports = {
'src/client/datascience/ipywidgets/remoteWidgetScriptSourceProvider.ts',
'src/client/datascience/ipywidgets/constants.ts',
'src/client/datascience/ipywidgets/ipywidgetHandler.ts',
'src/client/datascience/multiplexingDebugService.ts',
'src/client/datascience/raw-kernel/rawKernel.ts',
'src/client/datascience/crossProcessLock.ts',
'src/client/datascience/debugLocationTrackerFactory.ts',
Expand All @@ -732,7 +729,6 @@ module.exports = {
'src/client/datascience/jupyter/interpreter/jupyterInterpreterSelector.ts',
'src/client/datascience/jupyter/interpreter/jupyterInterpreterService.ts',
'src/client/datascience/jupyter/commandLineSelector.ts',
'src/client/datascience/jupyter/debuggerVariableRegistration.ts',
'src/client/datascience/jupyter/jupyterConnection.ts',
'src/client/datascience/jupyter/jupyterPasswordConnect.ts',
'src/client/datascience/jupyter/jupyterWebSocket.ts',
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -941,23 +941,23 @@
{
"command": "jupyter.debugNotebook",
"group": "navigation@3",
"when": "notebookType == 'jupyter-notebook' && isWorkspaceTrusted && jupyter.notebookeditor.canDebug && config.jupyter.experimental.debugging"
"when": "notebookType == 'jupyter-notebook' && isWorkspaceTrusted && config.jupyter.experimental.debugging"
}
],
"notebook/cell/title": [
{
"command": "jupyter.runByLine",
"when": "notebookType == jupyter-notebook && notebookCellType == code && isWorkspaceTrusted && jupyter.notebookeditor.canDebug && !jupyter.notebookeditor.runByLineInProgress && config.jupyter.experimental.debugging",
"when": "notebookType == jupyter-notebook && notebookCellType == code && isWorkspaceTrusted && !jupyter.notebookeditor.runByLineInProgress && config.jupyter.experimental.debugging",
"group": "inline/cell@0"
},
{
"command": "jupyter.runByLineContinue",
"when": "notebookType == jupyter-notebook && notebookCellType == code && isWorkspaceTrusted && jupyter.notebookeditor.canDebug && jupyter.notebookeditor.runByLineInProgress && config.jupyter.experimental.debugging",
"when": "notebookType == jupyter-notebook && notebookCellType == code && isWorkspaceTrusted && jupyter.notebookeditor.runByLineInProgress && config.jupyter.experimental.debugging",
"group": "inline/cell@0"
},
{
"command": "jupyter.runByLineStop",
"when": "notebookType == jupyter-notebook && notebookCellType == code && isWorkspaceTrusted && jupyter.notebookeditor.canDebug && jupyter.notebookeditor.runByLineInProgress && config.jupyter.experimental.debugging",
"when": "notebookType == jupyter-notebook && notebookCellType == code && isWorkspaceTrusted && jupyter.notebookeditor.runByLineInProgress && config.jupyter.experimental.debugging",
"group": "inline/cell@0"
}
],
Expand Down
4 changes: 0 additions & 4 deletions src/client/common/utils/localize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -961,10 +961,6 @@ export namespace DataScience {
);
export const noNotebookToDebug = localize('DataScience.noNotebookToDebug', 'No active notebook document to debug.');
export const cantStartDebugging = localize('DataScience.cantStartDebugging', "Can't start debugging.");
export const pythonKernelDebugAdapter = localize(
'DataScience.pythonKernelDebugAdapter',
'Python Kernel Debug Adapter'
);
}

// Skip using vscode-nls and instead just compute our strings based on key values. Key values
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { PYTHON_LANGUAGE } from '../../common/constants';
import { IDisposableRegistry } from '../../common/types';
import { Identifiers } from '../constants';
import { IJupyterDebugService, IJupyterVariables } from '../types';
import { pythonKernelDebugAdapter } from '../../debugger/constants';

@injectable()
export class DebuggerVariableRegistration implements IExtensionSingleActivationService, DebugAdapterTrackerFactory {
Expand All @@ -19,6 +20,7 @@ export class DebuggerVariableRegistration implements IExtensionSingleActivationS
) {}
public activate(): Promise<void> {
this.disposables.push(this.debugService.registerDebugAdapterTrackerFactory(PYTHON_LANGUAGE, this));
this.disposables.push(this.debugService.registerDebugAdapterTrackerFactory(pythonKernelDebugAdapter, this));
return Promise.resolve();
}

Expand Down
21 changes: 17 additions & 4 deletions src/client/datascience/jupyter/debuggerVariables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
import { inject, injectable, named } from 'inversify';
import * as path from 'path';

import { DebugAdapterTracker, Disposable, Event, EventEmitter } from 'vscode';
import { DebugAdapterTracker, DebugSession, Disposable, Event, EventEmitter } from 'vscode';
import { DebugProtocol } from 'vscode-debugprotocol';
import { IDebugService } from '../../common/application/types';
import { IDebugService, IVSCodeNotebook } from '../../common/application/types';
import { traceError } from '../../common/logger';
import { IConfigurationService, Resource } from '../../common/types';
import { IDebuggingManager } from '../../debugger/types';
import { sendTelemetryEvent } from '../../telemetry';
import { DataFrameLoading, GetVariableInfo, Identifiers, Telemetry } from '../constants';
import { DebugLocationTracker } from '../debugLocationTracker';
Expand Down Expand Up @@ -48,7 +49,9 @@ export class DebuggerVariables extends DebugLocationTracker

constructor(
@inject(IJupyterDebugService) @named(Identifiers.MULTIPLEXING_DEBUGSERVICE) private debugService: IDebugService,
@inject(IConfigurationService) private configService: IConfigurationService
@inject(IDebuggingManager) private readonly debuggingManager: IDebuggingManager,
@inject(IConfigurationService) private configService: IConfigurationService,
@inject(IVSCodeNotebook) private readonly vscNotebook: IVSCodeNotebook
) {
super(undefined);
}
Expand All @@ -58,7 +61,10 @@ export class DebuggerVariables extends DebugLocationTracker
}

public get active(): boolean {
return this.debugService.activeDebugSession !== undefined && this.debuggingStarted;
return (
(this.debugService.activeDebugSession !== undefined || this.getDebuggingManagerSession() !== undefined) &&
this.debuggingStarted
);
}

// IJupyterVariables implementation
Expand Down Expand Up @@ -401,6 +407,13 @@ export class DebuggerVariables extends DebugLocationTracker

this.refreshEventEmitter.fire();
}

private getDebuggingManagerSession(): DebugSession | undefined {
const activeNotebook = this.vscNotebook.activeNotebookEditor;
if (activeNotebook) {
return this.debuggingManager.getDebugSession(activeNotebook.document);
}
}
}

export function convertDebugProtocolVariableToIJupyterVariable(variable: DebugProtocol.Variable) {
Expand Down
20 changes: 7 additions & 13 deletions src/client/datascience/jupyter/jupyterVariables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import type { JSONObject } from '@phosphor/coreutils';
import { inject, injectable, named } from 'inversify';

import { CancellationToken, Event, EventEmitter } from 'vscode';
import { ServerStatus } from '../../../datascience-ui/interactive-common/mainState';
import { IDisposableRegistry } from '../../common/types';
import { captureTelemetry } from '../../telemetry';
import { Identifiers, Telemetry } from '../constants';
Expand Down Expand Up @@ -47,19 +46,19 @@ export class JupyterVariables implements IJupyterVariables {
request: IJupyterVariablesRequest,
notebook?: INotebook
): Promise<IJupyterVariablesResponse> {
return (await this.getVariableHandler(notebook)).getVariables(request, notebook);
return (await this.getVariableHandler()).getVariables(request, notebook);
}

public async getFullVariable(variable: IJupyterVariable, notebook?: INotebook): Promise<IJupyterVariable> {
return (await this.getVariableHandler(notebook)).getFullVariable(variable, notebook);
return (await this.getVariableHandler()).getFullVariable(variable, notebook);
}

public async getMatchingVariable(
name: string,
notebook?: INotebook,
cancelToken?: CancellationToken
): Promise<IJupyterVariable | undefined> {
return (await this.getVariableHandler(notebook)).getMatchingVariable(name, notebook, cancelToken);
return (await this.getVariableHandler()).getMatchingVariable(name, notebook, cancelToken);
}

public async getDataFrameInfo(
Expand All @@ -68,12 +67,7 @@ export class JupyterVariables implements IJupyterVariables {
sliceExpression?: string,
isRefresh?: boolean
): Promise<IJupyterVariable> {
return (await this.getVariableHandler(notebook)).getDataFrameInfo(
targetVariable,
notebook,
sliceExpression,
isRefresh
);
return (await this.getVariableHandler()).getDataFrameInfo(targetVariable, notebook, sliceExpression, isRefresh);
}

public async getDataFrameRows(
Expand All @@ -83,7 +77,7 @@ export class JupyterVariables implements IJupyterVariables {
notebook?: INotebook,
sliceExpression?: string
): Promise<JSONObject> {
return (await this.getVariableHandler(notebook)).getDataFrameRows(
return (await this.getVariableHandler()).getDataFrameRows(
targetVariable,
start,
end,
Expand All @@ -92,8 +86,8 @@ export class JupyterVariables implements IJupyterVariables {
);
}

private async getVariableHandler(notebook?: INotebook): Promise<IJupyterVariables> {
if (this.debuggerVariables.active && (!notebook || notebook.status === ServerStatus.Busy)) {
private async getVariableHandler(): Promise<IJupyterVariables> {
if (this.debuggerVariables.active) {
return this.debuggerVariables;
}

Expand Down
2 changes: 1 addition & 1 deletion src/client/datascience/multiplexingDebugService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export class MultiplexingDebugService implements IJupyterDebugService {
this.jupyterDebugService.stop();
} else {
// Stop our debugging UI session, no await as we just want it stopped
this.commandManager.executeCommand('workbench.action.debug.stop');
void this.commandManager.executeCommand('workbench.action.debug.stop');
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/client/datascience/serviceRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,14 @@ import { IApplicationEnvironment } from '../common/application/types';
import { NotebookIPyWidgetCoordinator } from './ipywidgets/notebookIPyWidgetCoordinator';
import { ExtensionRecommendationService } from './extensionRecommendation';
import { PythonVariablesRequester } from './jupyter/pythonVariableRequester';
import { DebuggingManager } from '../debugger/jupyter/debuggingManager';
import { DebuggingCellMap } from '../debugger/jupyter/debuggingCellMap';
import { NativeInteractiveWindowCommandListener } from './interactive-window/nativeInteractiveWindowCommandListener';
import { NativeInteractiveWindowProvider } from './interactive-window/nativeInteractiveWindowProvider';
import { JupyterPaths } from './kernel-launcher/jupyterPaths';
import { LocalKnownPathKernelSpecFinder } from './kernel-launcher/localKnownPathKernelSpecFinder';
import { LocalPythonAndRelatedNonPythonKernelSpecFinder } from './kernel-launcher/localPythonAndRelatedNonPythonKernelSpecFinder';
import { IDebuggingManager } from '../debugger/types';
import { DebuggingManager } from '../debugger/jupyter/debuggingManager';
import { HostJupyterExecution } from './jupyter/liveshare/hostJupyterExecution';
import { HostJupyterServer } from './jupyter/liveshare/hostJupyterServer';
import { HostRawNotebookProvider } from './raw-kernel/liveshare/hostRawNotebookProvider';
Expand Down Expand Up @@ -307,7 +308,7 @@ export function registerTypes(serviceManager: IServiceManager, inNotebookApiExpe
serviceManager.addBinding(INotebookExtensibility, INotebookExecutionLogger);
serviceManager.addSingleton<INotebookWatcher>(INotebookWatcher, NotebookWatcher);
serviceManager.addSingleton<IExtensionSyncActivationService>(IExtensionSyncActivationService, ExtensionRecommendationService);
serviceManager.addSingleton<IExtensionSingleActivationService>(IExtensionSingleActivationService, DebuggingManager);
serviceManager.addSingleton<IDebuggingManager>(IDebuggingManager, DebuggingManager, undefined, [IExtensionSingleActivationService]);
serviceManager.addSingleton<IDebuggingCellMap>(IDebuggingCellMap, DebuggingCellMap);
serviceManager.addBinding(IDebuggingCellMap, INotebookExecutionLogger);

Expand Down
9 changes: 8 additions & 1 deletion src/client/datascience/variablesView/variableView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import { WebviewViewHost } from '../webviews/webviewViewHost';
import { INotebookWatcher, IVariableViewPanelMapping } from './types';
import { VariableViewMessageListener } from './variableViewMessageListener';
import { ContextKey } from '../../common/contextKey';
import { IDebuggingManager } from '../../debugger/types';

const variableViewDir = path.join(EXTENSION_ROOT_DIR, 'out', 'datascience-ui', 'viewers');

Expand All @@ -61,7 +62,8 @@ export class VariableView extends WebviewViewHost<IVariableViewPanelMapping> imp
@unmanaged() private readonly jupyterVariableDataProviderFactory: IJupyterVariableDataProviderFactory,
@unmanaged() private readonly dataViewerFactory: IDataViewerFactory,
@unmanaged() private readonly notebookWatcher: INotebookWatcher,
@unmanaged() private readonly commandManager: ICommandManager
@unmanaged() private readonly commandManager: ICommandManager,
@unmanaged() private readonly debuggingManager: IDebuggingManager
) {
super(
configuration,
Expand All @@ -78,6 +80,7 @@ export class VariableView extends WebviewViewHost<IVariableViewPanelMapping> imp
this.notebookWatcher.onDidExecuteActiveNotebook(this.activeNotebookExecuted, this, this.disposables);
this.notebookWatcher.onDidChangeActiveNotebook(this.activeNotebookChanged, this, this.disposables);
this.notebookWatcher.onDidRestartActiveNotebook(this.activeNotebookRestarted, this, this.disposables);
this.debuggingManager.onDidFireVariablesEvent(this.sendRefreshMessage, this, this.disposables);

this.dataViewerChecker = new DataViewerChecker(configuration, appShell);
}
Expand Down Expand Up @@ -215,4 +218,8 @@ export class VariableView extends WebviewViewHost<IVariableViewPanelMapping> imp
private async activeNotebookRestarted() {
this.postMessage(InteractiveWindowMessages.RestartKernel).ignoreErrors();
}

private async sendRefreshMessage() {
this.postMessage(InteractiveWindowMessages.ForceVariableRefresh).ignoreErrors();
}
}
7 changes: 5 additions & 2 deletions src/client/datascience/variablesView/variableViewProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
import { isTestExecution } from '../../common/constants';
import { IConfigurationService, IDisposableRegistry } from '../../common/types';
import { createDeferred, Deferred } from '../../common/utils/async';
import { IDebuggingManager } from '../../debugger/types';
import { Identifiers } from '../constants';
import { IDataViewerFactory } from '../data-viewing/types';
import { ICodeCssGenerator, IJupyterVariableDataProviderFactory, IJupyterVariables, IThemeFinder } from '../types';
Expand Down Expand Up @@ -56,7 +57,8 @@ export class VariableViewProvider implements IVariableViewProvider {
private readonly jupyterVariableDataProviderFactory: IJupyterVariableDataProviderFactory,
@inject(IDataViewerFactory) private readonly dataViewerFactory: IDataViewerFactory,
@inject(INotebookWatcher) private readonly notebookWatcher: INotebookWatcher,
@inject(ICommandManager) private readonly commandManager: ICommandManager
@inject(ICommandManager) private readonly commandManager: ICommandManager,
@inject(IDebuggingManager) private readonly debuggingManager: IDebuggingManager
) {}

public async resolveWebviewView(
Expand All @@ -79,7 +81,8 @@ export class VariableViewProvider implements IVariableViewProvider {
this.jupyterVariableDataProviderFactory,
this.dataViewerFactory,
this.notebookWatcher,
this.commandManager
this.commandManager,
this.debuggingManager
);

// If someone is waiting for the variable view resolve that here
Expand Down
2 changes: 1 addition & 1 deletion src/client/debugger/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

'use strict';

export const DebuggerTypeName = 'python';
export const pythonKernelDebugAdapter = 'Python Kernel Debug Adapter';
Loading

0 comments on commit 8e06fe9

Please sign in to comment.