Skip to content

Commit

Permalink
try delegating even if we cannot get the full info (#16057)
Browse files Browse the repository at this point in the history
  • Loading branch information
amunger authored Sep 17, 2024
1 parent d4459ca commit 32f816c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/kernels/variables/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT License.

import { DebugProtocol } from 'vscode-debugprotocol';
import { IJupyterVariable } from './types';

export const DataViewableTypes: Set<string> = new Set<string>([
'DataFrame',
Expand All @@ -14,7 +15,7 @@ export const DataViewableTypes: Set<string> = new Set<string>([
'DataArray'
]);

export function convertDebugProtocolVariableToIJupyterVariable(variable: DebugProtocol.Variable) {
export function convertDebugProtocolVariableToIJupyterVariable(variable: DebugProtocol.Variable): IJupyterVariable {
return {
// If `evaluateName` is available use that. That is the name that we can eval in the debugger
// but it's an optional property so fallback to `variable.name`
Expand Down
1 change: 1 addition & 0 deletions src/kernels/variables/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export interface IJupyterVariable {
indexColumn?: string;
maximumRowChunkSize?: number;
fileName?: Uri;
frameId?: number;
}

export const IJupyterVariables = Symbol('IJupyterVariables');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export class DataViewerCommandRegistry implements IExtensionSyncActivationServic
private async delegateDataViewer(request: IJupyterVariable | IShowDataViewerFromVariablePanel) {
const variable = 'variable' in request ? await this.getVariableFromRequest(request) : request;
if (!variable) {
logger.error('Full variable info could not be retreived');
logger.error('Variable info could not be retreived');
sendTelemetryEvent(Telemetry.FailedShowDataViewer, undefined, {
reason: 'no variable info',
fromVariableView: false
Expand All @@ -106,7 +106,13 @@ export class DataViewerCommandRegistry implements IExtensionSyncActivationServic
const variable = convertDebugProtocolVariableToIJupyterVariable(
request.variable as unknown as DebugProtocol.Variable
);
return this.variableProvider.getFullVariable(variable);
try {
const result = await this.variableProvider.getFullVariable(variable);
return result;
} catch (e) {
logger.warn('Full variable info could not be retreived, will attempt with partial info.', e);
return variable;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export class DataViewerDelegator {
): { extension: Extension<unknown>; jupyterVariableViewers: IVariableViewer }[] {
const variableViewers = this.getVariableViewers();
return variableViewers
.filter((d) => d.jupyterVariableViewers.dataTypes.includes(variable.type))
.filter((d) => !variable.type || d.jupyterVariableViewers.dataTypes.includes(variable.type))
.filter((e) => e.extension.id !== JVSC_EXTENSION_ID);
}

Expand Down

0 comments on commit 32f816c

Please sign in to comment.