From 2165b7fc19db15d63943f4d94ba62f14167e1ee7 Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Sat, 13 Jul 2024 09:41:10 +1000 Subject: [PATCH 1/2] Additional data to compare conda environments.txt --- .../base/locators/common/nativePythonFinder.ts | 3 +++ .../locators/composite/envsCollectionService.ts | 16 ++++++++++++++-- src/client/telemetry/index.ts | 17 ++++++++++++++++- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/client/pythonEnvironments/base/locators/common/nativePythonFinder.ts b/src/client/pythonEnvironments/base/locators/common/nativePythonFinder.ts index 196808ac3e5f..3478f2d4cd0e 100644 --- a/src/client/pythonEnvironments/base/locators/common/nativePythonFinder.ts +++ b/src/client/pythonEnvironments/base/locators/common/nativePythonFinder.ts @@ -51,6 +51,9 @@ export type NativeCondaInfo = { canSpawnConda: boolean; condaRcs: string[]; envDirs: string[]; + environmentsTxt?: string; + environmentsTxtExists?: boolean; + environmentsFromTxt: string[]; }; export interface NativeGlobalPythonFinder extends Disposable { diff --git a/src/client/pythonEnvironments/base/locators/composite/envsCollectionService.ts b/src/client/pythonEnvironments/base/locators/composite/envsCollectionService.ts index e6a61964a245..2f20a971c3d1 100644 --- a/src/client/pythonEnvironments/base/locators/composite/envsCollectionService.ts +++ b/src/client/pythonEnvironments/base/locators/composite/envsCollectionService.ts @@ -359,6 +359,9 @@ export class EnvsCollectionService extends PythonEnvsWatcher traceError('Failed to get conda info', ex)) .then((conda) => conda?.getInfo()), @@ -405,12 +409,20 @@ export class EnvsCollectionService extends PythonEnvsWatcher traceError(`Failed to get conda envs from environments.txt`, ex)) .then((items) => items || []), + getCondaEnvironmentsTxt().catch(noop), ]); + const environmentsTxt = + Array.isArray(envTxt) && envTxt.length ? fsPath.normalize(envTxt[0]).toLowerCase() : undefined; if (nativeCondaInfo) { condaTelemetry.nativeCanSpawnConda = nativeCondaInfo.canSpawnConda; condaTelemetry.nativeCondaInfoEnvsDirs = new Set(nativeCondaInfo.envDirs).size; condaTelemetry.nativeCondaRcs = new Set(nativeCondaInfo.condaRcs).size; + + const nativeEnvTxt = fsPath.normalize(nativeCondaInfo.environmentsTxt || '').toLowerCase(); + condaTelemetry.nativeCondaEnvTxtExists = nativeCondaInfo.environmentsTxtExists == true; + condaTelemetry.nativeCondaEnvsFromTxt = (nativeCondaInfo.environmentsFromTxt || []).length; + condaTelemetry.nativeCondaEnvTxtSame = nativeEnvTxt === environmentsTxt; } condaTelemetry.condaEnvsInTxt = condaEnvsInEnvironmentsTxt.length; condaTelemetry.canSpawnConda = !!info; @@ -736,7 +748,7 @@ export class EnvsCollectionService extends PythonEnvsWatcher Date: Sat, 13 Jul 2024 09:44:03 +1000 Subject: [PATCH 2/2] oops --- .../base/locators/composite/envsCollectionService.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/pythonEnvironments/base/locators/composite/envsCollectionService.ts b/src/client/pythonEnvironments/base/locators/composite/envsCollectionService.ts index 2f20a971c3d1..f1a3e98b7467 100644 --- a/src/client/pythonEnvironments/base/locators/composite/envsCollectionService.ts +++ b/src/client/pythonEnvironments/base/locators/composite/envsCollectionService.ts @@ -420,7 +420,7 @@ export class EnvsCollectionService extends PythonEnvsWatcher