Skip to content

Commit

Permalink
Additional data to compare conda environments.txt (microsoft#23805)
Browse files Browse the repository at this point in the history
  • Loading branch information
DonJayamanne authored and eleanorjboyd committed Jul 30, 2024
1 parent 8c11a42 commit b3287ca
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ export type NativeCondaInfo = {
canSpawnConda: boolean;
condaRcs: string[];
envDirs: string[];
environmentsTxt?: string;
environmentsTxtExists?: boolean;
environmentsFromTxt: string[];
};

export interface NativeGlobalPythonFinder extends Disposable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,9 @@ export class EnvsCollectionService extends PythonEnvsWatcher<PythonEnvCollection
nativeCondaEnvDirsNotFound: number;
nativeCondaEnvDirsNotFoundHasEnvs: number;
nativeCondaEnvDirsNotFoundHasEnvsInTxt: number;
nativeCondaEnvTxtSame?: boolean;
nativeCondaEnvTxtExists?: boolean;
nativeCondaEnvsFromTxt: number;
};

const userProvidedCondaExe = fsPath
Expand All @@ -380,11 +383,12 @@ export class EnvsCollectionService extends PythonEnvsWatcher<PythonEnvCollection
nativeCondaEnvDirsNotFound: 0,
nativeCondaEnvDirsNotFoundHasEnvs: 0,
nativeCondaEnvDirsNotFoundHasEnvsInTxt: 0,
nativeCondaEnvsFromTxt: 0,
};

// Get conda telemetry
{
const [info, nativeCondaInfo, condaEnvsInEnvironmentsTxt] = await Promise.all([
const [info, nativeCondaInfo, condaEnvsInEnvironmentsTxt, envTxt] = await Promise.all([
Conda.getConda()
.catch((ex) => traceError('Failed to get conda info', ex))
.then((conda) => conda?.getInfo()),
Expand All @@ -405,12 +409,20 @@ export class EnvsCollectionService extends PythonEnvsWatcher<PythonEnvCollection
})
.catch((ex) => 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;
Expand Down Expand Up @@ -736,7 +748,7 @@ export class EnvsCollectionService extends PythonEnvsWatcher<PythonEnvCollection

// Intent is to capture time taken for discovery of all envs to complete the first time.
sendTelemetryEvent(EventName.PYTHON_INTERPRETER_DISCOVERY, elapsedTime, {
telVer: 5,
telVer: 6,
nativeDuration,
workspaceFolderCount: (workspace.workspaceFolders || []).length,
interpreters: this.cache.getAllEnvs().length,
Expand Down
17 changes: 16 additions & 1 deletion src/client/telemetry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1219,7 +1219,10 @@ export interface IEventNamePropertyMapping {
"nativeCondaRcsNotFound" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" },
"nativeCondaEnvDirsNotFound" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" },
"nativeCondaEnvDirsNotFoundHasEnvs" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" },
"nativeCondaEnvDirsNotFoundHasEnvsInTxt" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" }
"nativeCondaEnvDirsNotFoundHasEnvsInTxt" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" },
"nativeCondaEnvTxtSame" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "owner": "donjayamanne" },
"nativeCondaEnvsFromTxt" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" },
"nativeCondaEnvTxtExists" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "owner": "donjayamanne" }
}
*/
[EventName.PYTHON_INTERPRETER_DISCOVERY]: {
Expand Down Expand Up @@ -1487,6 +1490,18 @@ export interface IEventNamePropertyMapping {
* Number of environments of a specific type missing in Native Locator (compared to the Stable Locator).
*/
missingNativeCondaEnvs?: number;
/**
* Whether the env txt found by native locator is the same as that found by pythonn ext.
*/
nativeCondaEnvTxtSame?: boolean;
/**
* Number of environments found from env txt by native locator.
*/
nativeCondaEnvsFromTxt?: number;
/**
* Whether the env txt found by native locator exists.
*/
nativeCondaEnvTxtExists?: boolean;
/**
* Number of environments of a specific type missing in Native Locator (compared to the Stable Locator).
*/
Expand Down

0 comments on commit b3287ca

Please sign in to comment.