From 889fe68c0fc1e06db3ec6dae07e42332c1b0400f Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Thu, 14 Mar 2024 15:26:12 +1100 Subject: [PATCH 1/6] Do not log unnecessary warning msgs --- src/kernels/raw/launcher/kernelProcess.node.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/kernels/raw/launcher/kernelProcess.node.ts b/src/kernels/raw/launcher/kernelProcess.node.ts index 38ff66e21fb..dd9e0459457 100644 --- a/src/kernels/raw/launcher/kernelProcess.node.ts +++ b/src/kernels/raw/launcher/kernelProcess.node.ts @@ -221,7 +221,15 @@ export class KernelProcess extends ObservableDisposable implements IKernelProces // Capture stderr, incase kernel doesn't start. stderr += output.out; - if (output.out.trim().length) { + if ( + output.out.trim().length && + // Exclude these warning messages, as users get confused about these when sharing logs. + // I.e. they assume that issues in Jupyter ext are due to these warnings messages from ipykernel. + !output.out.includes('It seems that frozen modules are being used, which may') && + !output.out.includes('make the debugger miss breakpoints. Please pass -Xfrozen_modules=off') && + !output.out.includes('to python to disable frozen modules') && + !output.out.includes('Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION') + ) { traceWarning(`StdErr from Kernel Process ${output.out.trim()}`); } } else { From 2e749188104963f5cfd03232251f186f04855b2e Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Thu, 14 Mar 2024 15:29:13 +1100 Subject: [PATCH 2/6] More updatews --- src/kernels/execution/cellExecutionCreator.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/kernels/execution/cellExecutionCreator.ts b/src/kernels/execution/cellExecutionCreator.ts index e75825df1a8..6bea57f761f 100644 --- a/src/kernels/execution/cellExecutionCreator.ts +++ b/src/kernels/execution/cellExecutionCreator.ts @@ -72,9 +72,9 @@ export class NotebookCellExecutionWrapper implements NotebookCellExecution { try { this._impl.end(success, endTime, this.errorInfo); traceInfo( - `End cell ${this.cell.index} execution after ${ + `Cell ${this.cell.index} completed in ${ ((endTime || 0) - (this._startTime || 0)) / 1000 - }s, completed @ ${endTime}, started @ ${this._startTime}` + }s, started @ ${this._startTime}, completed @ ${endTime}` ); } finally { this._endCallback(); From a4bbe3fa1a32a1f645678920f16aa5b4f8f8af6f Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Thu, 14 Mar 2024 16:43:30 +1100 Subject: [PATCH 3/6] Reduced logging --- src/extension.node.ts | 7 +++- src/extension.web.ts | 7 +++- src/kernels/execution/cellExecutionCreator.ts | 2 +- src/kernels/helpers.node.ts | 1 - src/kernels/kernelRefreshIndicator.node.ts | 16 ++++---- src/kernels/kernelRefreshIndicator.web.ts | 6 +-- .../interpreterKernelSpecFinderHelper.node.ts | 38 ++++++++++++------- .../finder/localKernelSpecFinderBase.node.ts | 10 ++--- .../message/commonMessageCoordinator.ts | 4 -- .../message/ipyWidgetMessageDispatcher.ts | 1 - .../notebookIPyWidgetCoordinator.ts | 5 --- ...customEnvironmentVariablesProvider.node.ts | 2 +- src/platform/interpreter/condaService.node.ts | 2 +- .../environmentActivationService.node.ts | 12 +++--- .../notebookPythonPathService.node.ts | 26 +++++++------ 15 files changed, 77 insertions(+), 62 deletions(-) diff --git a/src/extension.node.ts b/src/extension.node.ts index 4a1a0a68012..795af46150f 100644 --- a/src/extension.node.ts +++ b/src/extension.node.ts @@ -100,6 +100,7 @@ import { import { setDisposableTracker } from './platform/common/utils/lifecycle'; import { sendTelemetryEvent } from './telemetry'; import { getVSCodeChannel } from './platform/common/application/applicationEnvironment'; +import { isUsingPylance } from './standalone/intellisense/notebookPythonPathService.node'; durations.codeLoadingTime = stopWatch.elapsedTime; @@ -305,7 +306,11 @@ function addOutputChannel(context: IExtensionContext, serviceManager: IServiceMa } const pylanceExtension = extensions.getExtension(PylanceExtension); if (pylanceExtension) { - standardOutputChannel.appendLine(`Pylance Extension Version: ${pylanceExtension.packageJSON['version']}.`); + standardOutputChannel.appendLine( + `Pylance Extension Version${isUsingPylance() ? '' : ' (Not Used) '}: ${ + pylanceExtension.packageJSON['version'] + }.` + ); } else { standardOutputChannel.appendLine('Pylance Extension not installed.'); } diff --git a/src/extension.web.ts b/src/extension.web.ts index 020e5a89842..533c168d4c6 100644 --- a/src/extension.web.ts +++ b/src/extension.web.ts @@ -104,6 +104,7 @@ import { initializeGlobals as initializeTelemetryGlobals } from './platform/tele import { setDisposableTracker } from './platform/common/utils/lifecycle'; import { sendTelemetryEvent } from './telemetry'; import { getVSCodeChannel } from './platform/common/application/applicationEnvironment'; +import { isUsingPylance } from './standalone/intellisense/notebookPythonPathService.node'; durations.codeLoadingTime = stopWatch.elapsedTime; @@ -272,7 +273,11 @@ function addOutputChannel(context: IExtensionContext, serviceManager: IServiceMa } const pylanceExtension = extensions.getExtension(PylanceExtension); if (pylanceExtension) { - standardOutputChannel.appendLine(`Pylance Extension Version: ${pylanceExtension.packageJSON['version']}.`); + standardOutputChannel.appendLine( + `Pylance Extension Version${isUsingPylance() ? '' : ' (Not Used) '}: ${ + pylanceExtension.packageJSON['version'] + }.` + ); } else { standardOutputChannel.appendLine('Pylance Extension not installed.'); } diff --git a/src/kernels/execution/cellExecutionCreator.ts b/src/kernels/execution/cellExecutionCreator.ts index 6bea57f761f..1074a949250 100644 --- a/src/kernels/execution/cellExecutionCreator.ts +++ b/src/kernels/execution/cellExecutionCreator.ts @@ -74,7 +74,7 @@ export class NotebookCellExecutionWrapper implements NotebookCellExecution { traceInfo( `Cell ${this.cell.index} completed in ${ ((endTime || 0) - (this._startTime || 0)) / 1000 - }s, started @ ${this._startTime}, completed @ ${endTime}` + }s (start: ${this._startTime}, end: ${endTime})` ); } finally { this._endCallback(); diff --git a/src/kernels/helpers.node.ts b/src/kernels/helpers.node.ts index 089233d7a19..02814ad06e6 100644 --- a/src/kernels/helpers.node.ts +++ b/src/kernels/helpers.node.ts @@ -54,7 +54,6 @@ export async function sendTelemetryForPythonKernelExecutable( } catch (ex) { traceError(`Failed to compare interpreters after ${stopWatch.elapsedTime}ms`, ex); } - traceVerbose(`End sendTelemetryForPythonKernelExecutable after ${stopWatch.elapsedTime}ms`); } /** diff --git a/src/kernels/kernelRefreshIndicator.node.ts b/src/kernels/kernelRefreshIndicator.node.ts index b3c189b1b5b..f95789efa03 100644 --- a/src/kernels/kernelRefreshIndicator.node.ts +++ b/src/kernels/kernelRefreshIndicator.node.ts @@ -9,7 +9,7 @@ import { InteractiveWindowView, JupyterNotebookView } from '../platform/common/c import { dispose } from '../platform/common/utils/lifecycle'; import { IDisposable, IDisposableRegistry } from '../platform/common/types'; import { IInterpreterService } from '../platform/interpreter/contracts'; -import { traceInfo } from '../platform/logging'; +import { traceVerbose } from '../platform/logging'; import { IKernelFinder } from './types'; import { isJupyterNotebook } from '../platform/common/utils'; import { noop } from '../platform/common/utils/misc'; @@ -57,7 +57,7 @@ export class KernelRefreshIndicator implements IExtensionSyncActivationService { const displayProgress = () => { const id = Date.now().toString(); - traceInfo(`Start refreshing Kernel Picker (${id})`); + traceVerbose(`Start refreshing Kernel Picker (${id})`); const taskNb = notebooks.createNotebookControllerDetectionTask(JupyterNotebookView); const taskIW = notebooks.createNotebookControllerDetectionTask(InteractiveWindowView); this.disposables.push(taskNb); @@ -66,7 +66,7 @@ export class KernelRefreshIndicator implements IExtensionSyncActivationService { this.kernelFinder.onDidChangeStatus( () => { if (this.kernelFinder.status === 'idle') { - traceInfo(`End refreshing Kernel Picker (${id})`); + traceVerbose(`End refreshing Kernel Picker (${id})`); taskNb.dispose(); taskIW.dispose(); } @@ -104,7 +104,7 @@ export class KernelRefreshIndicator implements IExtensionSyncActivationService { (e) => { if (!refreshedInterpreters && e && isJupyterNotebook(e.notebook)) { refreshedInterpreters = true; - traceInfo(`Start refreshing Interpreter Kernel Picker`); + traceVerbose(`Start refreshing Interpreter Kernel Picker`); this.interpreterService.refreshInterpreters().catch(noop); } }, @@ -115,7 +115,7 @@ export class KernelRefreshIndicator implements IExtensionSyncActivationService { (e) => { if (!refreshedInterpreters && isJupyterNotebook(e)) { refreshedInterpreters = true; - traceInfo(`Start refreshing Interpreter Kernel Picker`); + traceVerbose(`Start refreshing Interpreter Kernel Picker`); this.interpreterService.refreshInterpreters().catch(noop); } }, @@ -130,7 +130,7 @@ export class KernelRefreshIndicator implements IExtensionSyncActivationService { return kernelProgress; } id = Date.now().toString(); - traceInfo(`Start refreshing Kernel Picker (${id})`); + traceVerbose(`Start refreshing Kernel Picker (${id})`); kernelProgress = new DisposableStore( notebooks.createNotebookControllerDetectionTask(JupyterNotebookView), notebooks.createNotebookControllerDetectionTask(InteractiveWindowView) @@ -140,7 +140,7 @@ export class KernelRefreshIndicator implements IExtensionSyncActivationService { }; if (this.kernelFinder.status === 'idle') { - traceInfo(`End refreshing Kernel Picker (${id})`); + traceVerbose(`End refreshing Kernel Picker (${id})`); kernelProgress?.dispose(); } else { createProgressIndicator(); @@ -148,7 +148,7 @@ export class KernelRefreshIndicator implements IExtensionSyncActivationService { this.kernelFinder.onDidChangeStatus( () => { if (this.kernelFinder.status === 'idle') { - traceInfo(`End refreshing Kernel Picker (${id})`); + traceVerbose(`End refreshing Kernel Picker (${id})`); kernelProgress?.dispose(); } else { createProgressIndicator(); diff --git a/src/kernels/kernelRefreshIndicator.web.ts b/src/kernels/kernelRefreshIndicator.web.ts index 530f7d84808..f9351874cd0 100644 --- a/src/kernels/kernelRefreshIndicator.web.ts +++ b/src/kernels/kernelRefreshIndicator.web.ts @@ -7,7 +7,7 @@ import { IExtensionSyncActivationService } from '../platform/activation/types'; import { InteractiveWindowView, JupyterNotebookView } from '../platform/common/constants'; import { dispose } from '../platform/common/utils/lifecycle'; import { IDisposable, IDisposableRegistry } from '../platform/common/types'; -import { traceInfo } from '../platform/logging'; +import { traceVerbose } from '../platform/logging'; import { IKernelFinder } from './types'; /** * Ensures we refresh the list of Python environments upon opening a Notebook. @@ -54,7 +54,7 @@ export class KernelRefreshIndicator implements IExtensionSyncActivationService { } private displayProgressIndicator() { const id = Date.now().toString(); - traceInfo(`Start refreshing Kernel Picker (${id})`); + traceVerbose(`Start refreshing Kernel Picker (${id})`); const taskNb = notebooks.createNotebookControllerDetectionTask(JupyterNotebookView); const taskIW = notebooks.createNotebookControllerDetectionTask(InteractiveWindowView); this.disposables.push(taskNb); @@ -63,7 +63,7 @@ export class KernelRefreshIndicator implements IExtensionSyncActivationService { this.kernelFinder.onDidChangeStatus( () => { if (this.kernelFinder.status === 'idle') { - traceInfo(`End refreshing Kernel Picker (${id})`); + traceVerbose(`End refreshing Kernel Picker (${id})`); taskNb.dispose(); taskIW.dispose(); } diff --git a/src/kernels/raw/finder/interpreterKernelSpecFinderHelper.node.ts b/src/kernels/raw/finder/interpreterKernelSpecFinderHelper.node.ts index 472e0a8a752..d872de4753e 100644 --- a/src/kernels/raw/finder/interpreterKernelSpecFinderHelper.node.ts +++ b/src/kernels/raw/finder/interpreterKernelSpecFinderHelper.node.ts @@ -176,11 +176,24 @@ export class InterpreterSpecificKernelSpecsFinder extends DisposableBase { this.cancelToken.dispose(); this.cancelToken = this._register(new CancellationTokenSource()); this.kernelSpecPromise = this.listKernelSpecsImpl(); - void this.kernelSpecPromise.then(() => - traceVerbose( - `Kernels for interpreter ${this.interpreter.id} are ${Array.from(this._kernels.keys()).join(', ')}` - ) - ); + void this.kernelSpecPromise.then(() => { + switch (this._kernels.size) { + case 0: + traceVerbose(`No Kernels found in interpreter ${this.interpreter.id}`); + break; + case 1: + // Thats the default kernel we create for this interpreter. + // It will be the startUsingPythonInterpreter kernel. + // No need to log this, just noise. It will be an obvious entry + break; + default: + traceVerbose( + `Kernels for interpreter ${this.interpreter.id} are ${Array.from(this._kernels.keys()).join( + ', ' + )}` + ); + } + }); return this.kernelSpecPromise; } @@ -232,13 +245,13 @@ export class InterpreterSpecificKernelSpecsFinder extends DisposableBase { (!jupyterKernelSpec.env || Object.keys(jupyterKernelSpec.env).length === 0) && isDefaultKernelSpec(jupyterKernelSpec) ) { - traceVerbose( - `Hiding default kernel spec '${jupyterKernelSpec.display_name}', '${ - jupyterKernelSpec.name - }', ${getDisplayPath(jupyterKernelSpec.argv[0])} for interpreter ${getDisplayPath( - jupyterKernelSpec.interpreterPath - )} and spec ${getDisplayPath(jupyterKernelSpec.specFile)}` - ); + // traceVerbose( + // `Hiding default KernelSpec '${jupyterKernelSpec.name}', ${getDisplayPath( + // jupyterKernelSpec.argv[0] + // )} for interpreter ${getDisplayPath( + // jupyterKernelSpec.interpreterPath + // )} (KernelSpec file ${getDisplayPath(jupyterKernelSpec.specFile)})` + // ); return; } const kernelSpec = isKernelLaunchedViaLocalPythonIPyKernel(jupyterKernelSpec) @@ -567,7 +580,6 @@ export class GlobalPythonKernelSpecFinder implements IDisposable { ); } private async listKernelSpecsImpl() { - traceVerbose(`Finding Global Python KernelSpecs`); const cancelToken = this.cancelToken.token; const globalPythonKernelSpecs = this.listGlobalPythonKernelSpecs().filter( // Its impossible to have kernels registered by us that are in global. diff --git a/src/kernels/raw/finder/localKernelSpecFinderBase.node.ts b/src/kernels/raw/finder/localKernelSpecFinderBase.node.ts index ef65338acd0..b95e6419dbe 100644 --- a/src/kernels/raw/finder/localKernelSpecFinderBase.node.ts +++ b/src/kernels/raw/finder/localKernelSpecFinderBase.node.ts @@ -330,11 +330,11 @@ export async function loadKernelSpec( } let kernelJson: ReadWrite; try { - traceVerbose( - `Loading kernelspec from ${getDisplayPath(specPath)} ${ - interpreter?.uri ? `for ${getDisplayPath(interpreter.uri)}` : '' - }` - ); + // traceVerbose( + // `Loading kernelspec from ${getDisplayPath(specPath)} ${ + // interpreter?.uri ? `for ${getDisplayPath(interpreter.uri)}` : '' + // }` + // ); kernelJson = JSON.parse(await fs.readFile(specPath)); } catch (ex) { traceError(`Failed to parse kernelspec ${specPath}`, ex); diff --git a/src/notebooks/controllers/ipywidgets/message/commonMessageCoordinator.ts b/src/notebooks/controllers/ipywidgets/message/commonMessageCoordinator.ts index e27678fc6e6..7b1578bbf12 100644 --- a/src/notebooks/controllers/ipywidgets/message/commonMessageCoordinator.ts +++ b/src/notebooks/controllers/ipywidgets/message/commonMessageCoordinator.ts @@ -117,7 +117,6 @@ export class CommonMessageCoordinator { const stopWatch = new StopWatch(); if (!deferred.completed) { // Determine the version of ipywidgets and send the appropriate script url to the webview. - traceVerbose('Attempting to determine version of IPyWidgets'); const disposables: IDisposable[] = []; const kernelProvider = this.serviceContainer.get(IKernelProvider); const kernelPromise = createDeferred(); @@ -142,7 +141,6 @@ export class CommonMessageCoordinator { deferred.resolve(kernel.ipywidgetsVersion); } } else { - traceVerbose('Waiting for IPyWidgets version'); kernel.onIPyWidgetVersionResolved( () => { if (kernel.ipywidgetsVersion) { @@ -166,7 +164,6 @@ export class CommonMessageCoordinator { if (disposables.length) { this.disposables.push(...disposables); } - traceVerbose('Waiting for IPyWidgets version promise'); } // IPyWidgets scripts will not be loaded if we're unable to determine the version of IPyWidgets. const version = await deferred.promise; @@ -238,7 +235,6 @@ export class CommonMessageCoordinator { } private initialize() { - traceVerbose('initialize CommonMessageCoordinator'); // First hook up the widget script source that will listen to messages even before we start sending messages. this.getIPyWidgetScriptSource().initialize(); this.getIPyWidgetMessageDispatcher().initialize(); diff --git a/src/notebooks/controllers/ipywidgets/message/ipyWidgetMessageDispatcher.ts b/src/notebooks/controllers/ipywidgets/message/ipyWidgetMessageDispatcher.ts index 40ddda878a5..e668eb439f3 100644 --- a/src/notebooks/controllers/ipywidgets/message/ipyWidgetMessageDispatcher.ts +++ b/src/notebooks/controllers/ipywidgets/message/ipyWidgetMessageDispatcher.ts @@ -192,7 +192,6 @@ export class IPyWidgetMessageDispatcher implements IIPyWidgetMessageDispatcher { this.subscribeToKernelSocket(kernel); this.registerCommTargets(kernel); } - traceVerbose('IPyWidgetMessageDispatcher.initialize'); } protected raisePostMessage( message: IPyWidgetMessages, diff --git a/src/notebooks/controllers/notebookIPyWidgetCoordinator.ts b/src/notebooks/controllers/notebookIPyWidgetCoordinator.ts index 63753714a32..fddd0a8a237 100644 --- a/src/notebooks/controllers/notebookIPyWidgetCoordinator.ts +++ b/src/notebooks/controllers/notebookIPyWidgetCoordinator.ts @@ -150,18 +150,13 @@ export class NotebookIPyWidgetCoordinator implements IExtensionSyncActivationSer return; } if (this.notebookCommunications.has(editor)) { - traceVerbose( - `notebook communications already initialized for editor ${getDisplayPath(editor.notebook.uri)}` - ); return; } - traceVerbose(`Initialize notebook communications for editor ${getDisplayPath(editor.notebook.uri)}`); const comms = new NotebookCommunication(editor, controller); this.addNotebookDisposables(notebook, [comms]); this.notebookCommunications.set(editor, comms); // Create a handler for this notebook if we don't already have one. Since there's one of the notebookMessageCoordinator's for the // entire VS code session, we have a map of notebook document to message coordinator - traceVerbose(`Resolving notebook UI Comms (resolve) for ${getDisplayPath(notebook.uri)}`); let coordinator = this.messageCoordinators.get(notebook); if (!coordinator) { coordinator = new CommonMessageCoordinator(notebook, this.serviceContainer); diff --git a/src/platform/common/variables/customEnvironmentVariablesProvider.node.ts b/src/platform/common/variables/customEnvironmentVariablesProvider.node.ts index b359c2ac5c5..04dbe60afe7 100644 --- a/src/platform/common/variables/customEnvironmentVariablesProvider.node.ts +++ b/src/platform/common/variables/customEnvironmentVariablesProvider.node.ts @@ -44,7 +44,7 @@ export class CustomEnvironmentVariablesProvider implements ICustomEnvironmentVar dispose(this.disposables); } - @traceDecoratorVerbose('Get Custom Env Variables', TraceOptions.BeforeCall | TraceOptions.Arguments) + @traceDecoratorVerbose('Get Custom Env Variables', TraceOptions.Arguments) public async getEnvironmentVariables( resource: Resource, purpose: 'RunPythonCode' | 'RunNonPythonCode', diff --git a/src/platform/interpreter/condaService.node.ts b/src/platform/interpreter/condaService.node.ts index e8e6e082ac2..d01cde90907 100644 --- a/src/platform/interpreter/condaService.node.ts +++ b/src/platform/interpreter/condaService.node.ts @@ -83,7 +83,7 @@ export class CondaService { .then((api) => (api.getCondaFile ? api.getCondaFile() : undefined)); latestInfo .then((file) => { - traceVerbose(`Conda file returned by Python Extension is ${file}`); + traceVerbose(`Conda file is ${file}`); this._file = file ? Uri.file(file) : undefined; this.updateCache().catch(noop); }) diff --git a/src/platform/interpreter/environmentActivationService.node.ts b/src/platform/interpreter/environmentActivationService.node.ts index 7a0c5fe9b5d..cd1c2d56ad1 100644 --- a/src/platform/interpreter/environmentActivationService.node.ts +++ b/src/platform/interpreter/environmentActivationService.node.ts @@ -91,7 +91,7 @@ export class EnvironmentActivationService implements IEnvironmentActivationServi } return raceCancellation(token, promise); } - @traceDecoratorVerbose('Getting activated env variables', TraceOptions.BeforeCall | TraceOptions.Arguments) + @traceDecoratorVerbose('Getting activated env variables', TraceOptions.Arguments) private async getActivatedEnvironmentVariablesImpl( resource: Resource, @logValue('id') environment: Environment, @@ -201,9 +201,11 @@ export class EnvironmentActivationService implements IEnvironmentActivationServi if (env) { traceVerbose( - `Got env vars with python ${getDisplayPath(environment.path)}, with env var count ${ - Object.keys(env || {}).length - } in ${stopWatch.elapsedTime}ms. \n PATH value is ${env.PATH} and \n Path value is ${env.Path}` + `Got env vars from Python Ext in ${stopWatch.elapsedTime}ms for ${getDisplayPath( + environment.path + )}, with env var count ${Object.keys(env || {}).length}. \n PATH value is ${ + env.PATH + } and \n Path value is ${env.Path}` ); } else if (envType === EnvironmentType.Conda) { // We must get activated env variables for Conda env, if not running stuff against conda will not work. @@ -286,12 +288,12 @@ export class EnvironmentActivationService implements IEnvironmentActivationServi // Ensure the first path in PATH variable points to the directory of python executable. // We need to add this to ensure kernels start and work correctly, else things can fail miserably. - traceVerbose(`Prepend PATH with python bin for ${getDisplayPath(environment.path)}`); // This way all executables from that env are used. // This way shell commands such as `!pip`, `!python` end up pointing to the right executables. // Also applies to `!java` where java could be an executable in the conda bin directory. // Also required for conda environments that do not have Python installed (in the conda env). if (environment.executable.uri) { + traceVerbose(`Prepend PATH with python bin for ${getDisplayPath(environment.path)}`); this.envVarsService.prependPath(env, path.dirname(environment.executable.uri.fsPath)); } diff --git a/src/standalone/intellisense/notebookPythonPathService.node.ts b/src/standalone/intellisense/notebookPythonPathService.node.ts index c4431f1292a..b2c55723b91 100644 --- a/src/standalone/intellisense/notebookPythonPathService.node.ts +++ b/src/standalone/intellisense/notebookPythonPathService.node.ts @@ -17,6 +17,19 @@ import { raceTimeout } from '../../platform/common/utils/async'; import * as fs from 'fs-extra'; import { getNotebookUriFromInputBoxUri } from './notebookPythonPathService'; +export function isUsingPylance() { + const pythonConfig = workspace.getConfiguration('python'); + const languageServer = pythonConfig?.get('languageServer'); + + // Only enable the experiment if we're in the treatment group and the installed + // versions of Python and Pylance support the experiment. + + if (languageServer !== 'Pylance' && languageServer !== 'Default') { + return false; + } else { + return true; + } +} /** * Manages use of the Python extension's registerJupyterPythonPathFunction API which * enables us to provide the python.exe path for a notebook as required for Pylance's @@ -84,18 +97,7 @@ export class NotebookPythonPathService implements IExtensionSyncActivationServic */ public isUsingPylance() { if (this._isEnabled === undefined) { - const pythonConfig = workspace.getConfiguration('python'); - const languageServer = pythonConfig?.get('languageServer'); - - // Only enable the experiment if we're in the treatment group and the installed - // versions of Python and Pylance support the experiment. - this._isEnabled = false; - if (languageServer !== 'Pylance' && languageServer !== 'Default') { - traceInfo(`Not using Pylance`); - } else { - this._isEnabled = true; - traceInfo(`Using Pylance`); - } + this._isEnabled = isUsingPylance(); } return this._isEnabled; From 12e0ab1e36da0c9acb34724f0f04227a0df246e1 Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Thu, 14 Mar 2024 16:58:06 +1100 Subject: [PATCH 4/6] oops --- src/kernels/helpers.node.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/kernels/helpers.node.ts b/src/kernels/helpers.node.ts index 02814ad06e6..63421c72c60 100644 --- a/src/kernels/helpers.node.ts +++ b/src/kernels/helpers.node.ts @@ -5,7 +5,7 @@ import * as path from '../platform/vscode-path/path'; import type * as nbformat from '@jupyterlab/nbformat'; import { IJupyterKernelSpec, IKernelSession, isLocalConnection, KernelConnectionMetadata } from './types'; import { Uri } from 'vscode'; -import { traceError, traceVerbose } from '../platform/logging'; +import { traceError } from '../platform/logging'; import { Resource } from '../platform/common/types'; import { concatMultilineString } from '../platform/common/utils'; import { trackKernelResourceInformation } from './telemetry/helper'; From 8ebbda7099c30d17502713f445952d6ea9774d94 Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Fri, 15 Mar 2024 05:11:08 +1100 Subject: [PATCH 5/6] oops --- src/extension.node.ts | 2 +- src/extension.web.ts | 2 +- .../notebookPythonPathService.node.ts | 15 +-------------- .../intellisense/notebookPythonPathService.ts | 14 ++++++++++++++ 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/extension.node.ts b/src/extension.node.ts index 795af46150f..803e3846be2 100644 --- a/src/extension.node.ts +++ b/src/extension.node.ts @@ -100,7 +100,7 @@ import { import { setDisposableTracker } from './platform/common/utils/lifecycle'; import { sendTelemetryEvent } from './telemetry'; import { getVSCodeChannel } from './platform/common/application/applicationEnvironment'; -import { isUsingPylance } from './standalone/intellisense/notebookPythonPathService.node'; +import { isUsingPylance } from './standalone/intellisense/notebookPythonPathService'; durations.codeLoadingTime = stopWatch.elapsedTime; diff --git a/src/extension.web.ts b/src/extension.web.ts index 533c168d4c6..beccbd44404 100644 --- a/src/extension.web.ts +++ b/src/extension.web.ts @@ -104,7 +104,7 @@ import { initializeGlobals as initializeTelemetryGlobals } from './platform/tele import { setDisposableTracker } from './platform/common/utils/lifecycle'; import { sendTelemetryEvent } from './telemetry'; import { getVSCodeChannel } from './platform/common/application/applicationEnvironment'; -import { isUsingPylance } from './standalone/intellisense/notebookPythonPathService.node'; +import { isUsingPylance } from './standalone/intellisense/notebookPythonPathService'; durations.codeLoadingTime = stopWatch.elapsedTime; diff --git a/src/standalone/intellisense/notebookPythonPathService.node.ts b/src/standalone/intellisense/notebookPythonPathService.node.ts index b2c55723b91..85dac39fa51 100644 --- a/src/standalone/intellisense/notebookPythonPathService.node.ts +++ b/src/standalone/intellisense/notebookPythonPathService.node.ts @@ -15,21 +15,8 @@ import { IKernelProvider, isRemoteConnection } from '../../kernels/types'; import { noop } from '../../platform/common/utils/misc'; import { raceTimeout } from '../../platform/common/utils/async'; import * as fs from 'fs-extra'; -import { getNotebookUriFromInputBoxUri } from './notebookPythonPathService'; +import { getNotebookUriFromInputBoxUri, isUsingPylance } from './notebookPythonPathService'; -export function isUsingPylance() { - const pythonConfig = workspace.getConfiguration('python'); - const languageServer = pythonConfig?.get('languageServer'); - - // Only enable the experiment if we're in the treatment group and the installed - // versions of Python and Pylance support the experiment. - - if (languageServer !== 'Pylance' && languageServer !== 'Default') { - return false; - } else { - return true; - } -} /** * Manages use of the Python extension's registerJupyterPythonPathFunction API which * enables us to provide the python.exe path for a notebook as required for Pylance's diff --git a/src/standalone/intellisense/notebookPythonPathService.ts b/src/standalone/intellisense/notebookPythonPathService.ts index 359aaa910e0..52874372263 100644 --- a/src/standalone/intellisense/notebookPythonPathService.ts +++ b/src/standalone/intellisense/notebookPythonPathService.ts @@ -3,6 +3,20 @@ import { Uri, workspace } from 'vscode'; +export function isUsingPylance() { + const pythonConfig = workspace.getConfiguration('python'); + const languageServer = pythonConfig?.get('languageServer'); + + // Only enable the experiment if we're in the treatment group and the installed + // versions of Python and Pylance support the experiment. + + if (languageServer !== 'Pylance' && languageServer !== 'Default') { + return false; + } else { + return true; + } +} + export function getNotebookUriFromInputBoxUri(textDocumentUri: Uri): Uri | undefined { if (textDocumentUri.scheme !== 'vscode-interactive-input') { return undefined; From 1727a40b0a80a12c5162e0ec030168f66686de44 Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Fri, 15 Mar 2024 05:21:46 +1100 Subject: [PATCH 6/6] oops --- src/standalone/intellisense/notebookPythonPathService.node.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/standalone/intellisense/notebookPythonPathService.node.ts b/src/standalone/intellisense/notebookPythonPathService.node.ts index 85dac39fa51..d7b22d8afde 100644 --- a/src/standalone/intellisense/notebookPythonPathService.node.ts +++ b/src/standalone/intellisense/notebookPythonPathService.node.ts @@ -2,7 +2,7 @@ // Licensed under the MIT License. import { inject, injectable } from 'inversify'; -import { Disposable, extensions, Uri, workspace, window } from 'vscode'; +import { Disposable, extensions, Uri, window } from 'vscode'; import { INotebookEditorProvider } from '../../notebooks/types'; import { IExtensionSyncActivationService } from '../../platform/activation/types'; import { IPythonApiProvider, IPythonExtensionChecker } from '../../platform/api/types';