Skip to content

Commit

Permalink
More logging
Browse files Browse the repository at this point in the history
  • Loading branch information
DonJayamanne committed Jun 28, 2022
1 parent 3ca41b1 commit 8d88724
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/kernels/ipywidgets/baseIPyWidgetScriptManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ import { Uri } from 'vscode';
import { disposeAllDisposables } from '../../platform/common/helpers';
import { getDisplayPath } from '../../platform/common/platform/fs-paths';
import { IDisposable } from '../../platform/common/types';
import { traceWarning } from '../../platform/logging';
import { traceInfoIfCI, traceWarning } from '../../platform/logging';
import { sendTelemetryEvent, Telemetry } from '../../telemetry';
import { IKernel, isLocalConnection } from '../types';
import { getTelemetrySafeHashedString } from '../../platform/telemetry/helpers';
import * as stripComments from 'strip-comments';
import { IIPyWidgetScriptManager } from './types';
import { StopWatch } from '../../platform/common/utils/stopWatch';
import { isCI } from '../../platform/common/constants';

export function extractRequireConfigFromWidgetEntry(baseUrl: Uri, widgetFolderName: string, contents: string) {
// Look for `require.config(` or `window["require"].config` or `window['requirejs'].config`
Expand Down Expand Up @@ -148,9 +149,21 @@ export abstract class BaseIPyWidgetScriptManager implements IIPyWidgetScriptMana

try {
const config = await extractRequireConfigFromWidgetEntry(baseUrl, widgetFolderName, contents);
if (!config) {
let message = `Failed to extract require.config from widget for ${widgetFolderName} from ${getDisplayPath(
script
)}`;
if (isCI) {
message += `with contents ${contents}`;
}
traceWarning(message);
}
return config;
} catch (ex) {
traceWarning(`Failed to extract require.config entry from ${getDisplayPath(script)}`, ex);
traceWarning(
`Failed to extract require.config entry for ${widgetFolderName} from ${getDisplayPath(script)}`,
ex
);
}
}
private async getWidgetModuleMappingsImpl(): Promise<Record<string, Uri> | undefined> {
Expand All @@ -160,6 +173,7 @@ export abstract class BaseIPyWidgetScriptManager implements IIPyWidgetScriptMana
this.getNbExtensionsParentPath()
]);
if (!baseUrl) {
traceInfoIfCI('No base Url to retrieve widget module mappings');
return;
}
const widgetConfigs = await Promise.all(
Expand All @@ -173,6 +187,12 @@ export abstract class BaseIPyWidgetScriptManager implements IIPyWidgetScriptMana
delete config['@jupyter-widgets/base'];
delete config['@jupyter-widgets/controls'];
delete config['@jupyter-widgets/output'];
} else {
traceInfoIfCI(
`No config, entryPoints = ${JSON.stringify(entryPoints)}, widgetConfigs = ${JSON.stringify(
widgetConfigs
)}`
);
}
sendTelemetryEvent(Telemetry.DiscoverIPyWidgetNamesPerf, stopWatch.elapsedTime, {
type: isLocalConnection(this.kernel.kernelConnectionMetadata) ? 'local' : 'remote'
Expand Down

0 comments on commit 8d88724

Please sign in to comment.