diff --git a/src/client/common/experiments/helpers.ts b/src/client/common/experiments/helpers.ts deleted file mode 100644 index 127559f4fb12..000000000000 --- a/src/client/common/experiments/helpers.ts +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -'use strict'; - -import { IExperimentService } from '../types'; -import { DiscoveryVariants } from './groups'; - -export async function inDiscoveryExperiment(experimentService: IExperimentService): Promise { - const results = await Promise.all([ - experimentService.inExperiment(DiscoveryVariants.discoverWithFileWatching), - experimentService.inExperiment(DiscoveryVariants.discoveryWithoutFileWatching), - ]); - return results.includes(true); -} - -export function inDiscoveryExperimentSync(experimentService: IExperimentService): boolean { - return ( - experimentService.inExperimentSync(DiscoveryVariants.discoverWithFileWatching) || - experimentService.inExperimentSync(DiscoveryVariants.discoveryWithoutFileWatching) - ); -} diff --git a/src/client/common/installer/condaInstaller.ts b/src/client/common/installer/condaInstaller.ts index c74979541b11..6b0ebe992bff 100644 --- a/src/client/common/installer/condaInstaller.ts +++ b/src/client/common/installer/condaInstaller.ts @@ -3,11 +3,10 @@ // Licensed under the MIT License. import { inject, injectable } from 'inversify'; -import { ICondaService, ICondaLocatorService, IComponentAdapter } from '../../interpreter/contracts'; +import { ICondaService, IComponentAdapter } from '../../interpreter/contracts'; import { IServiceContainer } from '../../ioc/types'; import { ModuleInstallerType } from '../../pythonEnvironments/info'; -import { inDiscoveryExperiment } from '../experiments/helpers'; -import { ExecutionInfo, IConfigurationService, IExperimentService, Product } from '../types'; +import { ExecutionInfo, IConfigurationService, Product } from '../types'; import { isResource } from '../utils/misc'; import { ModuleInstaller, translateProductToModule } from './moduleInstaller'; import { InterpreterUri, ModuleInstallFlags } from './types'; @@ -77,10 +76,7 @@ export class CondaInstaller extends ModuleInstaller { const pythonPath = isResource(resource) ? this.serviceContainer.get(IConfigurationService).getSettings(resource).pythonPath : resource.path; - const experimentService = this.serviceContainer.get(IExperimentService); - const condaLocatorService = (await inDiscoveryExperiment(experimentService)) - ? this.serviceContainer.get(IComponentAdapter) - : this.serviceContainer.get(ICondaLocatorService); + const condaLocatorService = this.serviceContainer.get(IComponentAdapter); const info = await condaLocatorService.getCondaEnvironment(pythonPath); const args = [flags & ModuleInstallFlags.upgrade ? 'update' : 'install']; @@ -128,10 +124,7 @@ export class CondaInstaller extends ModuleInstaller { * Is the provided interprter a conda environment */ private async isCurrentEnvironmentACondaEnvironment(resource?: InterpreterUri): Promise { - const experimentService = this.serviceContainer.get(IExperimentService); - const condaService = (await inDiscoveryExperiment(experimentService)) - ? this.serviceContainer.get(IComponentAdapter) - : this.serviceContainer.get(ICondaLocatorService); + const condaService = this.serviceContainer.get(IComponentAdapter); const pythonPath = isResource(resource) ? this.serviceContainer.get(IConfigurationService).getSettings(resource).pythonPath : resource.path; diff --git a/src/client/common/installer/pipEnvInstaller.ts b/src/client/common/installer/pipEnvInstaller.ts index 432171769b17..04fcdb6fc91e 100644 --- a/src/client/common/installer/pipEnvInstaller.ts +++ b/src/client/common/installer/pipEnvInstaller.ts @@ -2,13 +2,12 @@ // Licensed under the MIT License. import { inject, injectable } from 'inversify'; -import { IInterpreterLocatorService, IInterpreterService, PIPENV_SERVICE } from '../../interpreter/contracts'; +import { IInterpreterService } from '../../interpreter/contracts'; import { IServiceContainer } from '../../ioc/types'; import { isPipenvEnvironmentRelatedToFolder } from '../../pythonEnvironments/common/environmentManagers/pipenv'; import { EnvironmentType, ModuleInstallerType } from '../../pythonEnvironments/info'; import { IWorkspaceService } from '../application/types'; -import { inDiscoveryExperiment } from '../experiments/helpers'; -import { ExecutionInfo, IExperimentService } from '../types'; +import { ExecutionInfo } from '../types'; import { isResource } from '../utils/misc'; import { ModuleInstaller } from './moduleInstaller'; import { InterpreterUri, ModuleInstallFlags } from './types'; @@ -37,27 +36,17 @@ export class PipEnvInstaller extends ModuleInstaller { } public async isSupported(resource?: InterpreterUri): Promise { if (isResource(resource)) { - const experimentService = this.serviceContainer.get(IExperimentService); - if (await inDiscoveryExperiment(experimentService)) { - const interpreter = await this.serviceContainer - .get(IInterpreterService) - .getActiveInterpreter(resource); - const workspaceFolder = resource - ? this.serviceContainer.get(IWorkspaceService).getWorkspaceFolder(resource) - : undefined; - if (!interpreter || !workspaceFolder || interpreter.envType !== EnvironmentType.Pipenv) { - return false; - } - // Install using `pipenv install` only if the active environment is related to the current folder. - return isPipenvEnvironmentRelatedToFolder(interpreter.path, workspaceFolder.uri.fsPath); - } else { - const pipenvs = this.serviceContainer.get( - IInterpreterLocatorService, - PIPENV_SERVICE, - ); - const interpreters = await pipenvs.getInterpreters(resource); - return interpreters.length > 0; + const interpreter = await this.serviceContainer + .get(IInterpreterService) + .getActiveInterpreter(resource); + const workspaceFolder = resource + ? this.serviceContainer.get(IWorkspaceService).getWorkspaceFolder(resource) + : undefined; + if (!interpreter || !workspaceFolder || interpreter.envType !== EnvironmentType.Pipenv) { + return false; } + // Install using `pipenv install` only if the active environment is related to the current folder. + return isPipenvEnvironmentRelatedToFolder(interpreter.path, workspaceFolder.uri.fsPath); } else { return resource.envType === EnvironmentType.Pipenv; } diff --git a/src/client/common/installer/poetryInstaller.ts b/src/client/common/installer/poetryInstaller.ts index 8ae795b43fe2..0690a9eeba96 100644 --- a/src/client/common/installer/poetryInstaller.ts +++ b/src/client/common/installer/poetryInstaller.ts @@ -4,24 +4,17 @@ 'use strict'; import { inject, injectable } from 'inversify'; -import * as path from 'path'; -import { Uri } from 'vscode'; import { IInterpreterService } from '../../interpreter/contracts'; import { IServiceContainer } from '../../ioc/types'; import { isPoetryEnvironmentRelatedToFolder } from '../../pythonEnvironments/common/environmentManagers/poetry'; import { EnvironmentType, ModuleInstallerType } from '../../pythonEnvironments/info'; import { IWorkspaceService } from '../application/types'; -import { inDiscoveryExperiment } from '../experiments/helpers'; -import { traceError } from '../logger'; -import { IFileSystem } from '../platform/types'; -import { IProcessServiceFactory } from '../process/types'; -import { ExecutionInfo, IConfigurationService, IExperimentService } from '../types'; +import { ExecutionInfo, IConfigurationService } from '../types'; import { isResource } from '../utils/misc'; import { ModuleInstaller } from './moduleInstaller'; import { InterpreterUri } from './types'; export const poetryName = 'poetry'; -const poetryFile = 'poetry.lock'; @injectable() export class PoetryInstaller extends ModuleInstaller { @@ -49,8 +42,6 @@ export class PoetryInstaller extends ModuleInstaller { @inject(IServiceContainer) serviceContainer: IServiceContainer, @inject(IWorkspaceService) private readonly workspaceService: IWorkspaceService, @inject(IConfigurationService) private readonly configurationService: IConfigurationService, - @inject(IFileSystem) private readonly fs: IFileSystem, - @inject(IProcessServiceFactory) private readonly processFactory: IProcessServiceFactory, ) { super(serviceContainer); } @@ -59,45 +50,22 @@ export class PoetryInstaller extends ModuleInstaller { if (!resource) { return false; } - const experimentService = this.serviceContainer.get(IExperimentService); - if (await inDiscoveryExperiment(experimentService)) { - if (!isResource(resource)) { - return false; - } - const interpreter = await this.serviceContainer - .get(IInterpreterService) - .getActiveInterpreter(resource); - const workspaceFolder = resource ? this.workspaceService.getWorkspaceFolder(resource) : undefined; - if (!interpreter || !workspaceFolder || interpreter.envType !== EnvironmentType.Poetry) { - return false; - } - // Install using poetry CLI only if the active poetry environment is related to the current folder. - return isPoetryEnvironmentRelatedToFolder( - interpreter.path, - workspaceFolder.uri.fsPath, - this.configurationService.getSettings(resource).poetryPath, - ); - } - const workspaceFolder = this.workspaceService.getWorkspaceFolder(isResource(resource) ? resource : undefined); - if (!workspaceFolder) { - return false; - } - if (!(await this.fs.fileExists(path.join(workspaceFolder.uri.fsPath, poetryFile)))) { + if (!isResource(resource)) { return false; } - return this.isPoetryAvailable(workspaceFolder.uri); - } - - protected async isPoetryAvailable(workfolder: Uri): Promise { - try { - const processService = await this.processFactory.create(workfolder); - const execPath = this.configurationService.getSettings(workfolder).poetryPath; - const result = await processService.shellExec(`${execPath} env list`, { cwd: workfolder.fsPath }); - return result && (result.stderr || '').trim().length === 0; - } catch (error) { - traceError(`${poetryFile} exists but Poetry not found`, error); + const interpreter = await this.serviceContainer + .get(IInterpreterService) + .getActiveInterpreter(resource); + const workspaceFolder = resource ? this.workspaceService.getWorkspaceFolder(resource) : undefined; + if (!interpreter || !workspaceFolder || interpreter.envType !== EnvironmentType.Poetry) { return false; } + // Install using poetry CLI only if the active poetry environment is related to the current folder. + return isPoetryEnvironmentRelatedToFolder( + interpreter.path, + workspaceFolder.uri.fsPath, + this.configurationService.getSettings(resource).poetryPath, + ); } protected async getExecutionInfo(moduleName: string, resource?: InterpreterUri): Promise { diff --git a/src/client/common/process/pythonExecutionFactory.ts b/src/client/common/process/pythonExecutionFactory.ts index e909a8d6dfe7..9a5a6c211f70 100644 --- a/src/client/common/process/pythonExecutionFactory.ts +++ b/src/client/common/process/pythonExecutionFactory.ts @@ -5,14 +5,13 @@ import { gte } from 'semver'; import { Uri } from 'vscode'; import { IEnvironmentActivationService } from '../../interpreter/activation/types'; -import { IComponentAdapter, ICondaLocatorService, ICondaService } from '../../interpreter/contracts'; +import { IComponentAdapter, ICondaService } from '../../interpreter/contracts'; import { IServiceContainer } from '../../ioc/types'; import { CondaEnvironmentInfo } from '../../pythonEnvironments/common/environmentManagers/conda'; -import { inDiscoveryExperiment } from '../experiments/helpers'; import { sendTelemetryEvent } from '../../telemetry'; import { EventName } from '../../telemetry/constants'; import { IFileSystem } from '../platform/types'; -import { IConfigurationService, IDisposableRegistry, IExperimentService, IInterpreterPathProxyService } from '../types'; +import { IConfigurationService, IDisposableRegistry, IInterpreterPathProxyService } from '../types'; import { ProcessService } from './proc'; import { createCondaEnv, createPythonEnv, createWindowsStoreEnv } from './pythonEnvironment'; import { createPythonProcessService } from './pythonProcess'; @@ -26,7 +25,6 @@ import { IPythonExecutionFactory, IPythonExecutionService, } from './types'; -import { isWindowsStoreInterpreter } from '../../pythonEnvironments/discovery/locators/services/windowsStoreInterpreter'; import { IInterpreterAutoSelectionService } from '../../interpreter/autoSelection/types'; import { sleep } from '../utils/async'; import { traceError } from '../logger'; @@ -50,7 +48,6 @@ export class PythonExecutionFactory implements IPythonExecutionFactory { @inject(ICondaService) private readonly condaService: ICondaService, @inject(IBufferDecoder) private readonly decoder: IBufferDecoder, @inject(IComponentAdapter) private readonly pyenvs: IComponentAdapter, - @inject(IExperimentService) private readonly experimentService: IExperimentService, @inject(IInterpreterAutoSelectionService) private readonly autoSelection: IInterpreterAutoSelectionService, @inject(IInterpreterPathProxyService) private readonly interpreterPathExpHelper: IInterpreterPathProxyService, ) { @@ -86,10 +83,7 @@ export class PythonExecutionFactory implements IPythonExecutionFactory { } const processService: IProcessService = await this.processServiceFactory.create(options.resource); - const windowsStoreInterpreterCheck = (await inDiscoveryExperiment(this.experimentService)) - ? // Class methods may depend on other properties which belong to the class, so bind the correct context. - this.pyenvs.isWindowsStoreInterpreter.bind(this.pyenvs) - : isWindowsStoreInterpreter; + const windowsStoreInterpreterCheck = this.pyenvs.isWindowsStoreInterpreter.bind(this.pyenvs); return createPythonService( pythonPath, @@ -136,9 +130,7 @@ export class PythonExecutionFactory implements IPythonExecutionFactory { const processServicePromise = processService ? Promise.resolve(processService) : this.processServiceFactory.create(resource); - const condaLocatorService = (await inDiscoveryExperiment(this.experimentService)) - ? this.serviceContainer.get(IComponentAdapter) - : this.serviceContainer.get(ICondaLocatorService); + const condaLocatorService = this.serviceContainer.get(IComponentAdapter); const [condaVersion, condaEnvironment, condaFile, procService] = await Promise.all([ this.condaService.getCondaVersion(), condaLocatorService.getCondaEnvironment(pythonPath), diff --git a/src/client/common/terminal/environmentActivationProviders/condaActivationProvider.ts b/src/client/common/terminal/environmentActivationProviders/condaActivationProvider.ts index eab916a7dd18..a65899904d95 100644 --- a/src/client/common/terminal/environmentActivationProviders/condaActivationProvider.ts +++ b/src/client/common/terminal/environmentActivationProviders/condaActivationProvider.ts @@ -9,12 +9,10 @@ import { inject, injectable } from 'inversify'; import * as path from 'path'; import { Uri } from 'vscode'; -import { IComponentAdapter, ICondaLocatorService, ICondaService } from '../../../interpreter/contracts'; +import { IComponentAdapter, ICondaService } from '../../../interpreter/contracts'; import { IPlatformService } from '../../platform/types'; -import { IConfigurationService, IExperimentService } from '../../types'; +import { IConfigurationService } from '../../types'; import { ITerminalActivationCommandProvider, TerminalShellType } from '../types'; -import { IServiceContainer } from '../../../ioc/types'; -import { inDiscoveryExperiment } from '../../experiments/helpers'; // Version number of conda that requires we call activate with 'conda activate' instead of just 'activate' const CondaRequiredMajor = 4; @@ -30,8 +28,6 @@ export class CondaActivationCommandProvider implements ITerminalActivationComman @inject(ICondaService) private readonly condaService: ICondaService, @inject(IPlatformService) private platform: IPlatformService, @inject(IConfigurationService) private configService: IConfigurationService, - @inject(IServiceContainer) private serviceContainer: IServiceContainer, - @inject(IExperimentService) private experimentService: IExperimentService, @inject(IComponentAdapter) private pyenvs: IComponentAdapter, ) {} @@ -62,10 +58,7 @@ export class CondaActivationCommandProvider implements ITerminalActivationComman pythonPath: string, targetShell: TerminalShellType, ): Promise { - const condaLocatorService = (await inDiscoveryExperiment(this.experimentService)) - ? this.pyenvs - : this.serviceContainer.get(ICondaLocatorService); - const envInfo = await condaLocatorService.getCondaEnvironment(pythonPath); + const envInfo = await this.pyenvs.getCondaEnvironment(pythonPath); if (!envInfo) { return undefined; } diff --git a/src/client/common/terminal/environmentActivationProviders/pipEnvActivationProvider.ts b/src/client/common/terminal/environmentActivationProviders/pipEnvActivationProvider.ts index de0e76fd6d42..04f696d0b9fb 100644 --- a/src/client/common/terminal/environmentActivationProviders/pipEnvActivationProvider.ts +++ b/src/client/common/terminal/environmentActivationProviders/pipEnvActivationProvider.ts @@ -10,9 +10,7 @@ import { IInterpreterService } from '../../../interpreter/contracts'; import { isPipenvEnvironmentRelatedToFolder } from '../../../pythonEnvironments/common/environmentManagers/pipenv'; import { EnvironmentType } from '../../../pythonEnvironments/info'; import { IWorkspaceService } from '../../application/types'; -import { inDiscoveryExperiment } from '../../experiments/helpers'; -import { IFileSystem } from '../../platform/types'; -import { IExperimentService, IToolExecutionPath, ToolExecutionPath } from '../../types'; +import { IToolExecutionPath, ToolExecutionPath } from '../../types'; import { ITerminalActivationCommandProvider } from '../types'; @injectable() @@ -23,8 +21,6 @@ export class PipEnvActivationCommandProvider implements ITerminalActivationComma @named(ToolExecutionPath.pipenv) private readonly pipEnvExecution: IToolExecutionPath, @inject(IWorkspaceService) private readonly workspaceService: IWorkspaceService, - @inject(IFileSystem) private readonly fs: IFileSystem, - @inject(IExperimentService) private readonly experimentService: IExperimentService, ) {} // eslint-disable-next-line class-methods-use-this @@ -40,14 +36,7 @@ export class PipEnvActivationCommandProvider implements ITerminalActivationComma // Activate using `pipenv shell` only if the current folder relates pipenv environment. const workspaceFolder = resource ? this.workspaceService.getWorkspaceFolder(resource) : undefined; if (workspaceFolder) { - if (await inDiscoveryExperiment(this.experimentService)) { - if (!(await isPipenvEnvironmentRelatedToFolder(interpreter.path, workspaceFolder?.uri.fsPath))) { - return undefined; - } - } else if ( - interpreter.pipEnvWorkspaceFolder && - !this.fs.arePathsSame(workspaceFolder.uri.fsPath, interpreter.pipEnvWorkspaceFolder) - ) { + if (!(await isPipenvEnvironmentRelatedToFolder(interpreter.path, workspaceFolder?.uri.fsPath))) { return undefined; } } diff --git a/src/client/common/terminal/helper.ts b/src/client/common/terminal/helper.ts index 283e4bec8ba1..eb810bf78c84 100644 --- a/src/client/common/terminal/helper.ts +++ b/src/client/common/terminal/helper.ts @@ -3,17 +3,16 @@ import { inject, injectable, multiInject, named } from 'inversify'; import { Terminal, Uri } from 'vscode'; -import { IComponentAdapter, ICondaLocatorService, IInterpreterService } from '../../interpreter/contracts'; +import { IComponentAdapter, IInterpreterService } from '../../interpreter/contracts'; import { IServiceContainer } from '../../ioc/types'; import { EnvironmentType, PythonEnvironment } from '../../pythonEnvironments/info'; import { sendTelemetryEvent } from '../../telemetry'; import { EventName } from '../../telemetry/constants'; import { ITerminalManager } from '../application/types'; -import { inDiscoveryExperiment } from '../experiments/helpers'; import '../extensions'; import { traceDecorators, traceError } from '../logger'; import { IPlatformService } from '../platform/types'; -import { IConfigurationService, IExperimentService, Resource } from '../types'; +import { IConfigurationService, Resource } from '../types'; import { OSType } from '../utils/platform'; import { ShellDetector } from './shellDetector'; import { @@ -131,10 +130,7 @@ export class TerminalHelper implements ITerminalHelper { ): Promise { const settings = this.configurationService.getSettings(resource); - const experimentService = this.serviceContainer.get(IExperimentService); - const condaService = (await inDiscoveryExperiment(experimentService)) - ? this.serviceContainer.get(IComponentAdapter) - : this.serviceContainer.get(ICondaLocatorService); + const condaService = this.serviceContainer.get(IComponentAdapter); // If we have a conda environment, then use that. const isCondaEnvironment = interpreter ? interpreter.envType === EnvironmentType.Conda diff --git a/src/client/interpreter/configuration/pythonPathUpdaterService.ts b/src/client/interpreter/configuration/pythonPathUpdaterService.ts index 3ea26ee437ed..43bce0dca0c6 100644 --- a/src/client/interpreter/configuration/pythonPathUpdaterService.ts +++ b/src/client/interpreter/configuration/pythonPathUpdaterService.ts @@ -1,12 +1,8 @@ import { inject, injectable } from 'inversify'; import * as path from 'path'; import { ConfigurationTarget, Uri, window } from 'vscode'; -import { inDiscoveryExperiment } from '../../common/experiments/helpers'; import { traceError } from '../../common/logger'; -import { IPythonExecutionFactory } from '../../common/process/types'; -import { IExperimentService } from '../../common/types'; import { StopWatch } from '../../common/utils/stopWatch'; -import { InterpreterInformation } from '../../pythonEnvironments/info'; import { sendTelemetryEvent } from '../../telemetry'; import { EventName } from '../../telemetry/constants'; import { PythonInterpreterTelemetry } from '../../telemetry/types'; @@ -18,9 +14,7 @@ export class PythonPathUpdaterService implements IPythonPathUpdaterServiceManage constructor( @inject(IPythonPathUpdaterServiceFactory) private readonly pythonPathSettingsUpdaterFactory: IPythonPathUpdaterServiceFactory, - @inject(IPythonExecutionFactory) private readonly executionFactory: IPythonExecutionFactory, @inject(IComponentAdapter) private readonly pyenvs: IComponentAdapter, - @inject(IExperimentService) private readonly experimentService: IExperimentService, ) {} public async updatePythonPath( @@ -58,20 +52,9 @@ export class PythonPathUpdaterService implements IPythonPathUpdaterServiceManage trigger, }; if (!failed && pythonPath) { - if (await inDiscoveryExperiment(this.experimentService)) { - const interpreterInfo = await this.pyenvs.getInterpreterInformation(pythonPath); - if (interpreterInfo) { - telemetryProperties.pythonVersion = interpreterInfo.version?.raw; - } - } else { - const processService = await this.executionFactory.create({ pythonPath }); - const info = await processService - .getInterpreterInformation() - .catch(() => undefined); - - if (info && info.version) { - telemetryProperties.pythonVersion = info.version.raw; - } + const interpreterInfo = await this.pyenvs.getInterpreterInformation(pythonPath); + if (interpreterInfo) { + telemetryProperties.pythonVersion = interpreterInfo.version?.raw; } } diff --git a/src/client/interpreter/display/progressDisplay.ts b/src/client/interpreter/display/progressDisplay.ts index 862434f13404..ada2594b2e37 100644 --- a/src/client/interpreter/display/progressDisplay.ts +++ b/src/client/interpreter/display/progressDisplay.ts @@ -7,13 +7,11 @@ import { inject, injectable } from 'inversify'; import { Disposable, ProgressLocation, ProgressOptions } from 'vscode'; import { IExtensionSingleActivationService } from '../../activation/types'; import { IApplicationShell } from '../../common/application/types'; -import { inDiscoveryExperiment } from '../../common/experiments/helpers'; import { traceDecorators } from '../../common/logger'; -import { IDisposableRegistry, IExperimentService } from '../../common/types'; +import { IDisposableRegistry } from '../../common/types'; import { createDeferred, Deferred } from '../../common/utils/async'; import { Interpreters } from '../../common/utils/localize'; -import { IServiceContainer } from '../../ioc/types'; -import { IComponentAdapter, IInterpreterLocatorProgressService } from '../contracts'; +import { IComponentAdapter } from '../contracts'; // The parts of IComponentAdapter used here. @injectable() @@ -24,32 +22,21 @@ export class InterpreterLocatorProgressStatubarHandler implements IExtensionSing constructor( @inject(IApplicationShell) private readonly shell: IApplicationShell, - @inject(IServiceContainer) - private readonly serviceContainer: IServiceContainer, @inject(IDisposableRegistry) private readonly disposables: Disposable[], @inject(IComponentAdapter) private readonly pyenvs: IComponentAdapter, - @inject(IExperimentService) private readonly experimentService: IExperimentService, ) {} public async activate(): Promise { - if (await inDiscoveryExperiment(this.experimentService)) { - this.pyenvs.onRefreshStart( - () => { - this.showProgress(); - if (this.pyenvs.refreshPromise) { - this.pyenvs.refreshPromise.then(() => this.hideProgress()); - } - }, - this, - this.disposables, - ); - } else { - const progressService = this.serviceContainer.get( - IInterpreterLocatorProgressService, - ); - progressService.onRefreshing(() => this.showProgress(), this, this.disposables); - progressService.onRefreshed(() => this.hideProgress(), this, this.disposables); - } + this.pyenvs.onRefreshStart( + () => { + this.showProgress(); + if (this.pyenvs.refreshPromise) { + this.pyenvs.refreshPromise.then(() => this.hideProgress()); + } + }, + this, + this.disposables, + ); } @traceDecorators.verbose('Display locator refreshing progress') diff --git a/src/client/interpreter/helpers.ts b/src/client/interpreter/helpers.ts index d419a1751e33..e54ae902dea7 100644 --- a/src/client/interpreter/helpers.ts +++ b/src/client/interpreter/helpers.ts @@ -1,26 +1,13 @@ import { inject, injectable } from 'inversify'; import { ConfigurationTarget, Uri } from 'vscode'; import { IDocumentManager, IWorkspaceService } from '../common/application/types'; -import { inDiscoveryExperiment } from '../common/experiments/helpers'; -import { traceError } from '../common/logger'; import { FileSystemPaths } from '../common/platform/fs-paths'; -import { IPythonExecutionFactory } from '../common/process/types'; -import { IExperimentService, IPersistentStateFactory, Resource } from '../common/types'; +import { Resource } from '../common/types'; import { IServiceContainer } from '../ioc/types'; import { compareSemVerLikeVersions } from '../pythonEnvironments/base/info/pythonVersion'; -import { isMacDefaultPythonPath } from '../pythonEnvironments/discovery'; -import { getInterpreterHash } from '../pythonEnvironments/discovery/locators/services/hashProvider'; -import { - EnvironmentType, - getEnvironmentTypeName, - InterpreterInformation, - PythonEnvironment, -} from '../pythonEnvironments/info'; +import { EnvironmentType, getEnvironmentTypeName, PythonEnvironment } from '../pythonEnvironments/info'; import { IComponentAdapter, IInterpreterHelper, WorkspacePythonPath } from './contracts'; -const EXPIRY_DURATION = 24 * 60 * 60 * 1000; -type CachedPythonInterpreter = Partial & { fileHash: string }; - export function isInterpreterLocatedInWorkspace(interpreter: PythonEnvironment, activeWorkspaceUri: Uri): boolean { const fileSystemPaths = FileSystemPaths.withDefaults(); const interpreterPath = fileSystemPaths.normCase(interpreter.path); @@ -45,15 +32,10 @@ function sortInterpreters(interpreters: PythonEnvironment[]): PythonEnvironment[ @injectable() export class InterpreterHelper implements IInterpreterHelper { - private readonly persistentFactory: IPersistentStateFactory; - constructor( @inject(IServiceContainer) private serviceContainer: IServiceContainer, @inject(IComponentAdapter) private readonly pyenvs: IComponentAdapter, - @inject(IExperimentService) private readonly experimentService: IExperimentService, - ) { - this.persistentFactory = this.serviceContainer.get(IPersistentStateFactory); - } + ) {} public getActiveWorkspaceUri(resource: Resource): WorkspacePythonPath | undefined { const workspaceService = this.serviceContainer.get(IWorkspaceService); @@ -81,57 +63,11 @@ export class InterpreterHelper implements IInterpreterHelper { } public async getInterpreterInformation(pythonPath: string): Promise> { - if (await inDiscoveryExperiment(this.experimentService)) { - return this.pyenvs.getInterpreterInformation(pythonPath); - } - - const fileHash = await getInterpreterHash(pythonPath).catch((ex) => { - traceError(`Failed to create File hash for interpreter ${pythonPath}`, ex); - return undefined; - }); - - const store = this.persistentFactory.createGlobalPersistentState( - `${pythonPath}.v3`, - undefined, - EXPIRY_DURATION, - ); - if (store.value && fileHash && store.value.fileHash === fileHash) { - return store.value; - } - const processService = await this.serviceContainer - .get(IPythonExecutionFactory) - .create({ pythonPath }); - - try { - const info = await processService - .getInterpreterInformation() - .catch(() => undefined); - if (!info) { - return; - } - - // If hash value is undefined then don't store it. - if (!fileHash) { - return info; - } - - const details = { - ...info, - fileHash, - }; - await store.updateValue(details); - return details; - } catch (ex) { - traceError(`Failed to get interpreter information for '${pythonPath}'`, ex); - } + return this.pyenvs.getInterpreterInformation(pythonPath); } public async isMacDefaultPythonPath(pythonPath: string): Promise { - if (await inDiscoveryExperiment(this.experimentService)) { - return this.pyenvs.isMacDefaultPythonPath(pythonPath); - } - - return isMacDefaultPythonPath(pythonPath); + return this.pyenvs.isMacDefaultPythonPath(pythonPath); } public getInterpreterTypeDisplayName(interpreterType: EnvironmentType): string { diff --git a/src/client/interpreter/virtualEnvs/virtualEnvPrompt.ts b/src/client/interpreter/virtualEnvs/virtualEnvPrompt.ts index b6d5c08a0312..5f7dd2499f04 100644 --- a/src/client/interpreter/virtualEnvs/virtualEnvPrompt.ts +++ b/src/client/interpreter/virtualEnvs/virtualEnvPrompt.ts @@ -5,29 +5,20 @@ import { inject, injectable } from 'inversify'; import { ConfigurationTarget, Disposable, Uri } from 'vscode'; import { IExtensionActivationService } from '../../activation/types'; import { IApplicationShell } from '../../common/application/types'; -import { inDiscoveryExperiment } from '../../common/experiments/helpers'; import { traceDecorators } from '../../common/logger'; -import { IDisposableRegistry, IExperimentService, IPersistentStateFactory } from '../../common/types'; +import { IDisposableRegistry, IPersistentStateFactory } from '../../common/types'; import { sleep } from '../../common/utils/async'; import { Common, Interpreters } from '../../common/utils/localize'; -import { IServiceContainer } from '../../ioc/types'; import { PythonEnvironment } from '../../pythonEnvironments/info'; import { sendTelemetryEvent } from '../../telemetry'; import { EventName } from '../../telemetry/constants'; import { IPythonPathUpdaterServiceManager } from '../configuration/types'; -import { - IComponentAdapter, - IInterpreterHelper, - IInterpreterLocatorService, - IInterpreterWatcherBuilder, - WORKSPACE_VIRTUAL_ENV_SERVICE, -} from '../contracts'; +import { IComponentAdapter, IInterpreterHelper } from '../contracts'; const doNotDisplayPromptStateKey = 'MESSAGE_KEY_FOR_VIRTUAL_ENV'; @injectable() export class VirtualEnvironmentPrompt implements IExtensionActivationService { constructor( - @inject(IServiceContainer) private readonly serviceContainer: IServiceContainer, @inject(IPersistentStateFactory) private readonly persistentStateFactory: IPersistentStateFactory, @inject(IInterpreterHelper) private readonly helper: IInterpreterHelper, @inject(IPythonPathUpdaterServiceManager) @@ -35,40 +26,18 @@ export class VirtualEnvironmentPrompt implements IExtensionActivationService { @inject(IDisposableRegistry) private readonly disposableRegistry: Disposable[], @inject(IApplicationShell) private readonly appShell: IApplicationShell, @inject(IComponentAdapter) private readonly pyenvs: IComponentAdapter, - @inject(IExperimentService) private readonly experimentService: IExperimentService, ) {} public async activate(resource: Uri): Promise { - if (await inDiscoveryExperiment(this.experimentService)) { - const disposable = this.pyenvs.onDidCreate(resource, () => this.handleNewEnvironment(resource)); - this.disposableRegistry.push(disposable); - } else { - const builder = this.serviceContainer.get(IInterpreterWatcherBuilder); - const watcher = await builder.getWorkspaceVirtualEnvInterpreterWatcher(resource); - watcher.onDidCreate( - () => { - this.handleNewEnvironment(resource).ignoreErrors(); - }, - this, - this.disposableRegistry, - ); - } + const disposable = this.pyenvs.onDidCreate(resource, () => this.handleNewEnvironment(resource)); + this.disposableRegistry.push(disposable); } @traceDecorators.error('Error in event handler for detection of new environment') protected async handleNewEnvironment(resource: Uri): Promise { // Wait for a while, to ensure environment gets created and is accessible (as this is slow on Windows) await sleep(1000); - let interpreters: PythonEnvironment[] | undefined = []; - if (await inDiscoveryExperiment(this.experimentService)) { - interpreters = await this.pyenvs.getWorkspaceVirtualEnvInterpreters(resource); - } else { - const workspaceVirtualEnvInterpreterLocator = this.serviceContainer.get( - IInterpreterLocatorService, - WORKSPACE_VIRTUAL_ENV_SERVICE, - ); - interpreters = await workspaceVirtualEnvInterpreterLocator.getInterpreters(resource); - } + const interpreters = await this.pyenvs.getWorkspaceVirtualEnvInterpreters(resource); const interpreter = Array.isArray(interpreters) && interpreters.length > 0 ? this.helper.getBestInterpreter(interpreters) diff --git a/src/client/jupyter/jupyterIntegration.ts b/src/client/jupyter/jupyterIntegration.ts index 8c51e76b4769..4fc5e7be6b4f 100644 --- a/src/client/jupyter/jupyterIntegration.ts +++ b/src/client/jupyter/jupyterIntegration.ts @@ -13,7 +13,6 @@ import { JUPYTER_EXTENSION_ID } from '../common/constants'; import { InterpreterUri, ModuleInstallFlags } from '../common/installer/types'; import { GLOBAL_MEMENTO, - IExperimentService, IExtensions, IInstaller, IMemento, @@ -35,8 +34,6 @@ import { } from '../interpreter/contracts'; import { PythonEnvironment } from '../pythonEnvironments/info'; import { IDataViewerDataProvider, IJupyterUriProvider } from './types'; -import { inDiscoveryExperiment } from '../common/experiments/helpers'; -import { isWindowsStoreInterpreter } from '../pythonEnvironments/discovery/locators/services/windowsStoreInterpreter'; interface ILanguageServer extends Disposable { readonly connection: ILanguageServerConnection; @@ -179,7 +176,6 @@ export class JupyterExtensionIntegration { @inject(IMemento) @named(GLOBAL_MEMENTO) private globalState: Memento, @inject(IInterpreterDisplay) private interpreterDisplay: IInterpreterDisplay, @inject(IComponentAdapter) private pyenvs: IComponentAdapter, - @inject(IExperimentService) private experimentService: IExperimentService, ) {} public registerApi(jupyterExtensionApi: JupyterExtensionApi): JupyterExtensionApi | undefined { @@ -198,12 +194,8 @@ export class JupyterExtensionIntegration { interpreter?: PythonEnvironment, allowExceptions?: boolean, ) => this.envActivation.getActivatedEnvironmentVariables(resource, interpreter, allowExceptions), - isWindowsStoreInterpreter: async (pythonPath: string): Promise => { - if (await inDiscoveryExperiment(this.experimentService)) { - return this.pyenvs.isWindowsStoreInterpreter(pythonPath); - } - return isWindowsStoreInterpreter(pythonPath); - }, + isWindowsStoreInterpreter: async (pythonPath: string): Promise => + this.pyenvs.isWindowsStoreInterpreter(pythonPath), getSuggestions: async (resource: Resource): Promise => this.interpreterSelector.getAllSuggestions(resource), getKnownSuggestions: (resource: Resource): IInterpreterQuickPickItem[] => diff --git a/src/client/pythonEnvironments/discovery/locators/services/condaLocatorService.ts b/src/client/pythonEnvironments/discovery/locators/services/condaLocatorService.ts index f20528d46624..d96117ea3717 100644 --- a/src/client/pythonEnvironments/discovery/locators/services/condaLocatorService.ts +++ b/src/client/pythonEnvironments/discovery/locators/services/condaLocatorService.ts @@ -6,19 +6,12 @@ import * as path from 'path'; import { ConfigurationChangeEvent, Uri } from 'vscode'; import { IWorkspaceService } from '../../../../common/application/types'; -import { inDiscoveryExperiment } from '../../../../common/experiments/helpers'; import { traceDecorators, traceError, traceVerbose, traceWarning } from '../../../../common/logger'; import { IFileSystem, IPlatformService } from '../../../../common/platform/types'; import { IProcessServiceFactory } from '../../../../common/process/types'; -import { - IConfigurationService, - IDisposableRegistry, - IExperimentService, - IPersistentStateFactory, -} from '../../../../common/types'; +import { IConfigurationService, IDisposableRegistry, IPersistentStateFactory } from '../../../../common/types'; import { cache } from '../../../../common/utils/decorators'; import { - IComponentAdapter, ICondaLocatorService, IInterpreterLocatorService, WINDOWS_REGISTRY_SERVICE, @@ -78,8 +71,6 @@ export class CondaLocatorService implements ICondaLocatorService { @inject(IConfigurationService) private configService: IConfigurationService, @inject(IDisposableRegistry) private disposableRegistry: IDisposableRegistry, @inject(IWorkspaceService) private readonly workspaceService: IWorkspaceService, - @inject(IComponentAdapter) private readonly pyenvs: IComponentAdapter, - @inject(IExperimentService) private readonly experimentService: IExperimentService, @inject(IServiceContainer) private readonly serviceContainer: IServiceContainer, ) { this.addCondaPathChangedHandler(); @@ -170,10 +161,6 @@ export class CondaLocatorService implements ICondaLocatorService { * @memberof CondaLocatorService */ public async isCondaEnvironment(interpreterPath: string): Promise { - if (await inDiscoveryExperiment(this.experimentService)) { - return this.pyenvs.isCondaEnvironment(interpreterPath); - } - const dir = path.dirname(interpreterPath); const { isWindows } = this.platform; const condaMetaDirectory = isWindows ? path.join(dir, 'conda-meta') : path.join(dir, '..', 'conda-meta'); @@ -184,10 +171,6 @@ export class CondaLocatorService implements ICondaLocatorService { * Return (env name, interpreter filename) for the interpreter. */ public async getCondaEnvironment(interpreterPath: string): Promise<{ name: string; path: string } | undefined> { - if (await inDiscoveryExperiment(this.experimentService)) { - return this.pyenvs.getCondaEnvironment(interpreterPath); - } - const isCondaEnv = await this.isCondaEnvironment(interpreterPath); if (!isCondaEnv) { return undefined; diff --git a/src/client/pythonEnvironments/discovery/locators/services/condaService.ts b/src/client/pythonEnvironments/discovery/locators/services/condaService.ts index 82551230809c..a8b80b3d6906 100644 --- a/src/client/pythonEnvironments/discovery/locators/services/condaService.ts +++ b/src/client/pythonEnvironments/discovery/locators/services/condaService.ts @@ -3,14 +3,12 @@ import * as path from 'path'; import { parse, SemVer } from 'semver'; import { ConfigurationChangeEvent, Uri } from 'vscode'; import { IWorkspaceService } from '../../../../common/application/types'; -import { inDiscoveryExperiment } from '../../../../common/experiments/helpers'; import { traceDecorators, traceWarning } from '../../../../common/logger'; import { IFileSystem, IPlatformService } from '../../../../common/platform/types'; import { IProcessServiceFactory } from '../../../../common/process/types'; -import { IExperimentService, IConfigurationService, IDisposableRegistry } from '../../../../common/types'; +import { IConfigurationService, IDisposableRegistry } from '../../../../common/types'; import { cache } from '../../../../common/utils/decorators'; -import { ICondaService, ICondaLocatorService } from '../../../../interpreter/contracts'; -import { IServiceContainer } from '../../../../ioc/types'; +import { ICondaService } from '../../../../interpreter/contracts'; import { Conda, CondaInfo } from '../../../common/environmentManagers/conda'; /** @@ -26,8 +24,6 @@ export class CondaService implements ICondaService { @inject(IProcessServiceFactory) private processServiceFactory: IProcessServiceFactory, @inject(IPlatformService) private platform: IPlatformService, @inject(IFileSystem) private fileSystem: IFileSystem, - @inject(IServiceContainer) private readonly serviceContainer: IServiceContainer, - @inject(IExperimentService) private readonly experimentService: IExperimentService, @inject(IConfigurationService) private readonly configService: IConfigurationService, @inject(IDisposableRegistry) private disposableRegistry: IDisposableRegistry, @inject(IWorkspaceService) private readonly workspaceService: IWorkspaceService, @@ -39,9 +35,6 @@ export class CondaService implements ICondaService { * Return the path to the "conda file". */ public async getCondaFile(): Promise { - if (!(await inDiscoveryExperiment(this.experimentService))) { - return this.serviceContainer.get(ICondaLocatorService).getCondaFile(); - } if (!this.condaFile) { this.condaFile = this.getCondaFileImpl(); } @@ -148,10 +141,8 @@ export class CondaService implements ICondaService { * The result is cached for 30s. */ @cache(60_000) + // eslint-disable-next-line class-methods-use-this public async _getCondaInfo(): Promise { - if (!(await inDiscoveryExperiment(this.experimentService))) { - return this.serviceContainer.get(ICondaLocatorService).getCondaInfo(); - } const conda = await Conda.getConda(); return conda?.getInfo(); } diff --git a/src/test/common/experiments/helpers.unit.test.ts b/src/test/common/experiments/helpers.unit.test.ts deleted file mode 100644 index 0b9f8a19bc75..000000000000 --- a/src/test/common/experiments/helpers.unit.test.ts +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -'use strict'; - -import { expect } from 'chai'; -import { anything, instance, mock, when } from 'ts-mockito'; -import { DiscoveryVariants } from '../../../client/common/experiments/groups'; -import { inDiscoveryExperiment } from '../../../client/common/experiments/helpers'; -import { ExperimentService } from '../../../client/common/experiments/service'; -import { IExperimentService } from '../../../client/common/types'; - -suite('Experiments - inDiscoveryExperiment()', () => { - let experimentService: IExperimentService; - setup(() => { - experimentService = mock(ExperimentService); - }); - - test('Return true if in discoverWithFileWatching experiment', async () => { - when(experimentService.inExperiment(DiscoveryVariants.discoverWithFileWatching)).thenResolve(true); - const result = await inDiscoveryExperiment(instance(experimentService)); - expect(result).to.equal(true); - }); - - test('Return true if in discoveryWithoutFileWatching experiment', async () => { - when(experimentService.inExperiment(DiscoveryVariants.discoveryWithoutFileWatching)).thenResolve(true); - const result = await inDiscoveryExperiment(instance(experimentService)); - expect(result).to.equal(true); - }); - - test('Return false otherwise', async () => { - when(experimentService.inExperiment(anything())).thenResolve(false); - const result = await inDiscoveryExperiment(instance(experimentService)); - expect(result).to.equal(false); - }); -}); diff --git a/src/test/common/installer/condaInstaller.unit.test.ts b/src/test/common/installer/condaInstaller.unit.test.ts index f322031f81e1..6da63804ea2d 100644 --- a/src/test/common/installer/condaInstaller.unit.test.ts +++ b/src/test/common/installer/condaInstaller.unit.test.ts @@ -17,7 +17,7 @@ import { IExperimentService, IPythonSettings, } from '../../../client/common/types'; -import { ICondaService, ICondaLocatorService } from '../../../client/interpreter/contracts'; +import { ICondaService, IComponentAdapter } from '../../../client/interpreter/contracts'; import { ServiceContainer } from '../../../client/ioc/container'; import { IServiceContainer } from '../../../client/ioc/types'; import { CondaEnvironmentInfo } from '../../../client/pythonEnvironments/common/environmentManagers/conda'; @@ -27,7 +27,7 @@ suite('Common - Conda Installer', () => { let installer: CondaInstallerTest; let serviceContainer: IServiceContainer; let condaService: ICondaService; - let condaLocatorService: ICondaLocatorService; + let condaLocatorService: IComponentAdapter; let configService: IConfigurationService; let experimentService: IExperimentService; class CondaInstallerTest extends CondaInstaller { @@ -39,13 +39,11 @@ suite('Common - Conda Installer', () => { serviceContainer = mock(ServiceContainer); condaService = mock(CondaService); experimentService = mock(); - condaLocatorService = mock(); + condaLocatorService = mock(); when(experimentService.inExperiment(DiscoveryVariants.discoverWithFileWatching)).thenResolve(false); configService = mock(ConfigurationService); when(serviceContainer.get(ICondaService)).thenReturn(instance(condaService)); - when(serviceContainer.get(ICondaLocatorService)).thenReturn( - instance(condaLocatorService), - ); + when(serviceContainer.get(IComponentAdapter)).thenReturn(instance(condaLocatorService)); when(serviceContainer.get(IConfigurationService)).thenReturn(instance(configService)); when(serviceContainer.get(IExperimentService)).thenReturn(instance(experimentService)); installer = new CondaInstallerTest(instance(serviceContainer)); diff --git a/src/test/common/installer/pipEnvInstaller.unit.test.ts b/src/test/common/installer/pipEnvInstaller.unit.test.ts index c1858e2a2ee1..58a6206e1c5a 100644 --- a/src/test/common/installer/pipEnvInstaller.unit.test.ts +++ b/src/test/common/installer/pipEnvInstaller.unit.test.ts @@ -14,7 +14,7 @@ import { IExperimentService } from '../../../client/common/types'; import { IInterpreterLocatorService, IInterpreterService, PIPENV_SERVICE } from '../../../client/interpreter/contracts'; import { IServiceContainer } from '../../../client/ioc/types'; import * as pipEnvHelper from '../../../client/pythonEnvironments/common/environmentManagers/pipenv'; -import { EnvironmentType, PythonEnvironment } from '../../../client/pythonEnvironments/info'; +import { EnvironmentType } from '../../../client/pythonEnvironments/info'; suite('PipEnv installer', async () => { let serviceContainer: TypeMoq.IMock; @@ -89,21 +89,7 @@ suite('PipEnv installer', async () => { expect(result).to.equal(false, 'Should be false'); }); - test('If InterpreterUri is Resource, and if resource contains pipEnv interpreters, return true', async () => { - const resource = Uri.parse('a'); - locatorService - .setup((p) => p.getInterpreters(resource)) - .returns(() => - Promise.resolve([ - TypeMoq.Mock.ofType().object, - TypeMoq.Mock.ofType().object, - ]), - ); - const result = await pipEnvInstaller.isSupported(resource); - expect(result).to.equal(true, 'Should be true'); - }); - - test('When in experiment, if active environment is pipenv and is related to workspace folder, return true', async () => { + test('If active environment is pipenv and is related to workspace folder, return true', async () => { const resource = Uri.parse('a'); experimentService.reset(); experimentService @@ -120,7 +106,7 @@ suite('PipEnv installer', async () => { expect(result).to.equal(true, 'Should be true'); }); - test('When in experiment, if active environment is not pipenv, return false', async () => { + test('If active environment is not pipenv, return false', async () => { const resource = Uri.parse('a'); experimentService.reset(); experimentService @@ -137,7 +123,7 @@ suite('PipEnv installer', async () => { expect(result).to.equal(false, 'Should be false'); }); - test('When in experiment, if active environment is pipenv but not related to workspace folder, return false', async () => { + test('If active environment is pipenv but not related to workspace folder, return false', async () => { const resource = Uri.parse('a'); experimentService.reset(); experimentService diff --git a/src/test/common/installer/poetryInstaller.unit.test.ts b/src/test/common/installer/poetryInstaller.unit.test.ts index 256c4db092af..83265f956e8d 100644 --- a/src/test/common/installer/poetryInstaller.unit.test.ts +++ b/src/test/common/installer/poetryInstaller.unit.test.ts @@ -14,11 +14,7 @@ import { WorkspaceService } from '../../../client/common/application/workspace'; import { PythonSettings } from '../../../client/common/configSettings'; import { ConfigurationService } from '../../../client/common/configuration/service'; import { PoetryInstaller } from '../../../client/common/installer/poetryInstaller'; -import { FileSystem } from '../../../client/common/platform/fileSystem'; -import { IFileSystem } from '../../../client/common/platform/types'; -import { ProcessService } from '../../../client/common/process/proc'; -import { ProcessServiceFactory } from '../../../client/common/process/processFactory'; -import { ExecutionResult, IProcessServiceFactory, ShellOptions } from '../../../client/common/process/types'; +import { ExecutionResult, ShellOptions } from '../../../client/common/process/types'; import { ExecutionInfo, IConfigurationService, IExperimentService } from '../../../client/common/types'; import { ServiceContainer } from '../../../client/ioc/container'; import { IInterpreterService } from '../../../client/interpreter/contracts'; @@ -38,10 +34,8 @@ suite('Module Installer - Poetry', () => { let poetryInstaller: TestInstaller; let workspaceService: IWorkspaceService; let configurationService: IConfigurationService; - let fileSystem: IFileSystem; let experimentService: IExperimentService; let interpreterService: IInterpreterService; - let processServiceFactory: IProcessServiceFactory; let serviceContainer: ServiceContainer; let shellExecute: sinon.SinonStub; @@ -53,8 +47,6 @@ suite('Module Installer - Poetry', () => { when(serviceContainer.get(IExperimentService)).thenReturn(instance(experimentService)); workspaceService = mock(WorkspaceService); configurationService = mock(ConfigurationService); - fileSystem = mock(FileSystem); - processServiceFactory = mock(ProcessServiceFactory); shellExecute = sinon.stub(externalDependencies, 'shellExecute'); shellExecute.callsFake((command: string, options: ShellOptions) => { @@ -76,8 +68,6 @@ suite('Module Installer - Poetry', () => { instance(serviceContainer), instance(workspaceService), instance(configurationService), - instance(fileSystem), - instance(processServiceFactory), ); }); @@ -108,63 +98,6 @@ suite('Module Installer - Poetry', () => { assert.equal(supported, false); }); - test('Is not supported when the poetry file does not exists', async () => { - const uri = Uri.file(__dirname); - when(workspaceService.getWorkspaceFolder(anything())).thenReturn({ uri, name: '', index: 0 }); - when(fileSystem.fileExists(anything())).thenResolve(false); - - const supported = await poetryInstaller.isSupported(Uri.file(__filename)); - - assert.equal(supported, false); - }); - test('Is not supported when the poetry is not available (with stderr)', async () => { - const uri = Uri.file(__dirname); - const processService = mock(ProcessService); - const settings = mock(PythonSettings); - - when(configurationService.getSettings(anything())).thenReturn(instance(settings)); - when(settings.poetryPath).thenReturn('poetry'); - when(workspaceService.getWorkspaceFolder(anything())).thenReturn({ uri, name: '', index: 0 }); - when(fileSystem.fileExists(anything())).thenResolve(true); - when(processServiceFactory.create(anything())).thenResolve(instance(processService)); - when(processService.shellExec(anything(), anything())).thenResolve({ stderr: 'Kaboom', stdout: '' }); - - const supported = await poetryInstaller.isSupported(Uri.file(__filename)); - - assert.equal(supported, false); - }); - test('Is not supported when the poetry is not available (with error running poetry)', async () => { - const uri = Uri.file(__dirname); - const processService = mock(ProcessService); - const settings = mock(PythonSettings); - - when(configurationService.getSettings(anything())).thenReturn(instance(settings)); - when(settings.poetryPath).thenReturn('poetry'); - when(workspaceService.getWorkspaceFolder(anything())).thenReturn({ uri, name: '', index: 0 }); - when(fileSystem.fileExists(anything())).thenResolve(true); - when(processServiceFactory.create(anything())).thenResolve(instance(processService)); - when(processService.shellExec(anything(), anything())).thenReject(new Error('Kaboom')); - - const supported = await poetryInstaller.isSupported(Uri.file(__filename)); - - assert.equal(supported, false); - }); - test('Is supported', async () => { - const uri = Uri.file(__dirname); - const processService = mock(ProcessService); - const settings = mock(PythonSettings); - - when(configurationService.getSettings(uri)).thenReturn(instance(settings)); - when(settings.poetryPath).thenReturn('poetry path'); - when(workspaceService.getWorkspaceFolder(anything())).thenReturn({ uri, name: '', index: 0 }); - when(fileSystem.fileExists(anything())).thenResolve(true); - when(processServiceFactory.create(uri)).thenResolve(instance(processService)); - when(processService.shellExec('poetry path env list', anything())).thenResolve({ stderr: '', stdout: '' }); - - const supported = await poetryInstaller.isSupported(Uri.file(__filename)); - - assert.equal(supported, true); - }); test('Get Executable info', async () => { const uri = Uri.file(__dirname); const settings = mock(PythonSettings); @@ -190,7 +123,7 @@ suite('Module Installer - Poetry', () => { execPath: 'poetry path', }); }); - test('When in experiment, is supported returns true if selected interpreter is related to the workspace', async () => { + test('Is supported returns true if selected interpreter is related to the workspace', async () => { const uri = Uri.file(project1); const settings = mock(PythonSettings); @@ -209,7 +142,7 @@ suite('Module Installer - Poetry', () => { assert.equal(supported, true); }); - test('When in experiment, is supported returns true if no interpreter is selected', async () => { + test('Is supported returns true if no interpreter is selected', async () => { const uri = Uri.file(project1); const settings = mock(PythonSettings); @@ -224,7 +157,7 @@ suite('Module Installer - Poetry', () => { assert.equal(supported, false); }); - test('When in experiment, is supported returns false if selected interpreter is not related to the workspace', async () => { + test('Is supported returns false if selected interpreter is not related to the workspace', async () => { const uri = Uri.file(project1); const settings = mock(PythonSettings); @@ -243,7 +176,7 @@ suite('Module Installer - Poetry', () => { assert.equal(supported, false); }); - test('When in experiment, is supported returns false if selected interpreter is not of Poetry type', async () => { + test('Is supported returns false if selected interpreter is not of Poetry type', async () => { const uri = Uri.file(project1); const settings = mock(PythonSettings); diff --git a/src/test/common/process/pythonExecutionFactory.unit.test.ts b/src/test/common/process/pythonExecutionFactory.unit.test.ts index 852afa046912..09249c1f0f9d 100644 --- a/src/test/common/process/pythonExecutionFactory.unit.test.ts +++ b/src/test/common/process/pythonExecutionFactory.unit.test.ts @@ -24,29 +24,16 @@ import { IProcessServiceFactory, IPythonExecutionService, } from '../../../client/common/process/types'; -import { - IConfigurationService, - IDisposableRegistry, - IExperimentService, - IInterpreterPathProxyService, -} from '../../../client/common/types'; +import { IConfigurationService, IDisposableRegistry, IInterpreterPathProxyService } from '../../../client/common/types'; import { Architecture } from '../../../client/common/utils/platform'; import { EnvironmentActivationService } from '../../../client/interpreter/activation/service'; import { IEnvironmentActivationService } from '../../../client/interpreter/activation/types'; -import { - IComponentAdapter, - ICondaLocatorService, - ICondaService, - IInterpreterService, -} from '../../../client/interpreter/contracts'; +import { IComponentAdapter, ICondaService, IInterpreterService } from '../../../client/interpreter/contracts'; import { InterpreterService } from '../../../client/interpreter/interpreterService'; import { ServiceContainer } from '../../../client/ioc/container'; import { CondaService } from '../../../client/pythonEnvironments/discovery/locators/services/condaService'; import { EnvironmentType, PythonEnvironment } from '../../../client/pythonEnvironments/info'; -import * as ExperimentHelpers from '../../../client/common/experiments/helpers'; import * as WindowsStoreInterpreter from '../../../client/pythonEnvironments/discovery/locators/services/windowsStoreInterpreter'; -import { ExperimentService } from '../../../client/common/experiments/service'; -import { DiscoveryVariants } from '../../../client/common/experiments/groups'; import { IInterpreterAutoSelectionService } from '../../../client/interpreter/autoSelection/types'; const pythonInterpreter: PythonEnvironment = { @@ -93,15 +80,12 @@ suite('Process - PythonExecutionFactory', () => { let processFactory: IProcessServiceFactory; let configService: IConfigurationService; let condaService: ICondaService; - let condaLocatorService: ICondaLocatorService; let processLogger: IProcessLogger; let processService: typemoq.IMock; let interpreterService: IInterpreterService; let pyenvs: IComponentAdapter; - let experimentService: IExperimentService; let executionService: typemoq.IMock; let isWindowsStoreInterpreterStub: sinon.SinonStub; - let inDiscoveryExperimentStub: sinon.SinonStub; let autoSelection: IInterpreterAutoSelectionService; let interpreterPathExpHelper: IInterpreterPathProxyService; setup(() => { @@ -110,14 +94,10 @@ suite('Process - PythonExecutionFactory', () => { processFactory = mock(ProcessServiceFactory); configService = mock(ConfigurationService); condaService = mock(CondaService); - condaLocatorService = mock(); processLogger = mock(ProcessLogger); autoSelection = mock(); interpreterPathExpHelper = mock(); when(interpreterPathExpHelper.get(anything())).thenReturn('selected interpreter path'); - experimentService = mock(ExperimentService); - when(experimentService.inExperiment(DiscoveryVariants.discoverWithFileWatching)).thenResolve(false); - when(experimentService.inExperiment(DiscoveryVariants.discoveryWithoutFileWatching)).thenResolve(false); pyenvs = mock(); when(pyenvs.isWindowsStoreInterpreter(anyString())).thenResolve(true); @@ -147,9 +127,7 @@ suite('Process - PythonExecutionFactory', () => { when(serviceContainer.get(IInterpreterService)).thenReturn( instance(interpreterService), ); - when(serviceContainer.get(ICondaLocatorService)).thenReturn( - instance(condaLocatorService), - ); + when(serviceContainer.get(IComponentAdapter)).thenReturn(instance(pyenvs)); when(serviceContainer.tryGet(IInterpreterService)).thenReturn( instance(interpreterService), ); @@ -161,15 +139,12 @@ suite('Process - PythonExecutionFactory', () => { instance(condaService), instance(bufferDecoder), instance(pyenvs), - instance(experimentService), instance(autoSelection), instance(interpreterPathExpHelper), ); isWindowsStoreInterpreterStub = sinon.stub(WindowsStoreInterpreter, 'isWindowsStoreInterpreter'); isWindowsStoreInterpreterStub.resolves(true); - - inDiscoveryExperimentStub = sinon.stub(ExperimentHelpers, 'inDiscoveryExperiment'); }); teardown(() => sinon.restore()); @@ -191,7 +166,6 @@ suite('Process - PythonExecutionFactory', () => { test('If interpreter is explicitly set, ensure we use it', async () => { const pythonSettings = mock(PythonSettings); when(processFactory.create(resource)).thenResolve(processService.object); - inDiscoveryExperimentStub.resolves(true); when(activationHelper.getActivatedEnvironmentVariables(resource)).thenResolve({ x: '1' }); reset(interpreterPathExpHelper); when(interpreterPathExpHelper.get(anything())).thenReturn('python'); @@ -295,7 +269,6 @@ suite('Process - PythonExecutionFactory', () => { when(processFactory.create(resource)).thenResolve(processService.object); when(pythonSettings.pythonPath).thenReturn(pythonPath); when(configService.getSettings(resource)).thenReturn(instance(pythonSettings)); - inDiscoveryExperimentStub.resolves(true); const service = await factory.create({ resource }); @@ -303,30 +276,9 @@ suite('Process - PythonExecutionFactory', () => { verify(processFactory.create(resource)).once(); verify(pythonSettings.pythonPath).once(); verify(pyenvs.isWindowsStoreInterpreter(pythonPath)).once(); - sinon.assert.calledOnce(inDiscoveryExperimentStub); sinon.assert.notCalled(isWindowsStoreInterpreterStub); }); - test("Ensure `create` returns a WindowsStorePythonProcess instance if it's a windows store intepreter path and we're not in the discovery experiment", async () => { - const pythonPath = 'path/to/python'; - const pythonSettings = mock(PythonSettings); - - when(processFactory.create(resource)).thenResolve(processService.object); - when(pythonSettings.pythonPath).thenReturn(pythonPath); - when(configService.getSettings(resource)).thenReturn(instance(pythonSettings)); - inDiscoveryExperimentStub.resolves(false); - - const service = await factory.create({ resource }); - - expect(service).to.not.equal(undefined); - verify(processFactory.create(resource)).once(); - verify(pythonSettings.pythonPath).once(); - verify(pyenvs.isWindowsStoreInterpreter(pythonPath)).never(); - sinon.assert.calledOnce(inDiscoveryExperimentStub); - sinon.assert.calledOnce(isWindowsStoreInterpreterStub); - sinon.assert.calledWith(isWindowsStoreInterpreterStub, pythonPath); - }); - test('Ensure `create` returns a CondaExecutionService instance if createCondaExecutionService() returns a valid object', async function () { return this.skip(); @@ -338,7 +290,7 @@ suite('Process - PythonExecutionFactory', () => { when(pythonSettings.pythonPath).thenReturn(pythonPath); when(configService.getSettings(resource)).thenReturn(instance(pythonSettings)); when(condaService.getCondaVersion()).thenResolve(new SemVer(CONDA_RUN_VERSION)); - when(condaLocatorService.getCondaEnvironment(pythonPath)).thenResolve({ + when(pyenvs.getCondaEnvironment(pythonPath)).thenResolve({ name: 'foo', path: 'path/to/foo/env', }); @@ -350,7 +302,7 @@ suite('Process - PythonExecutionFactory', () => { verify(processFactory.create(resource)).once(); verify(pythonSettings.pythonPath).once(); verify(condaService.getCondaVersion()).once(); - verify(condaLocatorService.getCondaEnvironment(pythonPath)).once(); + verify(pyenvs.getCondaEnvironment(pythonPath)).once(); verify(condaService.getCondaFile()).once(); }); @@ -371,7 +323,7 @@ suite('Process - PythonExecutionFactory', () => { verify(processFactory.create(resource)).once(); verify(pythonSettings.pythonPath).once(); verify(condaService.getCondaVersion()).once(); - verify(condaLocatorService.getCondaEnvironment(pythonPath)).once(); + verify(pyenvs.getCondaEnvironment(pythonPath)).once(); verify(condaService.getCondaFile()).once(); }); @@ -388,7 +340,7 @@ suite('Process - PythonExecutionFactory', () => { }); when(configService.getSettings(resource)).thenReturn(instance(pythonSettings)); when(condaService.getCondaVersion()).thenResolve(new SemVer(CONDA_RUN_VERSION)); - when(condaLocatorService.getCondaEnvironment(anyString())).thenResolve({ + when(pyenvs.getCondaEnvironment(anyString())).thenResolve({ name: 'foo', path: 'path/to/foo/env', }); @@ -400,9 +352,9 @@ suite('Process - PythonExecutionFactory', () => { verify(condaService.getCondaFile()).once(); if (!interpreter) { verify(pythonSettings.pythonPath).once(); - verify(condaLocatorService.getCondaEnvironment(pythonPath)).once(); + verify(pyenvs.getCondaEnvironment(pythonPath)).once(); } else { - verify(condaLocatorService.getCondaEnvironment(interpreter!.path)).once(); + verify(pyenvs.getCondaEnvironment(interpreter!.path)).once(); } }); @@ -441,7 +393,7 @@ suite('Process - PythonExecutionFactory', () => { test('Ensure `createCondaExecutionService` creates a CondaExecutionService instance if there is a conda environment', async () => { const pythonPath = 'path/to/python'; - when(condaLocatorService.getCondaEnvironment(pythonPath)).thenResolve({ + when(pyenvs.getCondaEnvironment(pythonPath)).thenResolve({ name: 'foo', path: 'path/to/foo/env', }); @@ -452,14 +404,14 @@ suite('Process - PythonExecutionFactory', () => { expect(result).to.not.equal(undefined); verify(condaService.getCondaVersion()).once(); - verify(condaLocatorService.getCondaEnvironment(pythonPath)).once(); + verify(pyenvs.getCondaEnvironment(pythonPath)).once(); verify(condaService.getCondaFile()).once(); }); test('Ensure `createCondaExecutionService` instantiates a ProcessService instance if the process argument is undefined', async () => { const pythonPath = 'path/to/python'; when(processFactory.create(resource)).thenResolve(processService.object); - when(condaLocatorService.getCondaEnvironment(pythonPath)).thenResolve({ + when(pyenvs.getCondaEnvironment(pythonPath)).thenResolve({ name: 'foo', path: 'path/to/foo/env', }); @@ -471,13 +423,13 @@ suite('Process - PythonExecutionFactory', () => { expect(result).to.not.equal(undefined); verify(processFactory.create(resource)).once(); verify(condaService.getCondaVersion()).once(); - verify(condaLocatorService.getCondaEnvironment(pythonPath)).once(); + verify(pyenvs.getCondaEnvironment(pythonPath)).once(); verify(condaService.getCondaFile()).once(); }); test('Ensure `createCondaExecutionService` returns undefined if there is no conda environment', async () => { const pythonPath = 'path/to/python'; - when(condaLocatorService.getCondaEnvironment(pythonPath)).thenResolve(undefined); + when(pyenvs.getCondaEnvironment(pythonPath)).thenResolve(undefined); when(condaService.getCondaVersion()).thenResolve(new SemVer(CONDA_RUN_VERSION)); const result = await factory.createCondaExecutionService(pythonPath, processService.object); @@ -487,7 +439,7 @@ suite('Process - PythonExecutionFactory', () => { 'createCondaExecutionService should return undefined if not in a conda environment', ); verify(condaService.getCondaVersion()).once(); - verify(condaLocatorService.getCondaEnvironment(pythonPath)).once(); + verify(pyenvs.getCondaEnvironment(pythonPath)).once(); verify(condaService.getCondaFile()).once(); }); @@ -502,7 +454,7 @@ suite('Process - PythonExecutionFactory', () => { 'createCondaExecutionService should return undefined if not in a conda environment', ); verify(condaService.getCondaVersion()).once(); - verify(condaLocatorService.getCondaEnvironment(pythonPath)).once(); + verify(pyenvs.getCondaEnvironment(pythonPath)).once(); verify(condaService.getCondaFile()).once(); }); }); diff --git a/src/test/common/terminals/activation.conda.unit.test.ts b/src/test/common/terminals/activation.conda.unit.test.ts index 537abb253858..8cac5418fb92 100644 --- a/src/test/common/terminals/activation.conda.unit.test.ts +++ b/src/test/common/terminals/activation.conda.unit.test.ts @@ -30,7 +30,7 @@ import { ITerminalSettings, } from '../../../client/common/types'; import { getNamesAndValues } from '../../../client/common/utils/enum'; -import { IComponentAdapter, ICondaLocatorService, ICondaService } from '../../../client/interpreter/contracts'; +import { IComponentAdapter, ICondaService } from '../../../client/interpreter/contracts'; import { InterpreterService } from '../../../client/interpreter/interpreterService'; import { IServiceContainer } from '../../../client/ioc/types'; @@ -45,7 +45,6 @@ suite('Terminal Environment Activation conda', () => { let processService: TypeMoq.IMock; let procServiceFactory: TypeMoq.IMock; let condaService: TypeMoq.IMock; - let condaLocatorService: TypeMoq.IMock; let experimentService: TypeMoq.IMock; let componentAdapter: TypeMoq.IMock; let configService: TypeMoq.IMock; @@ -68,10 +67,9 @@ suite('Terminal Environment Activation conda', () => { fileSystem = TypeMoq.Mock.ofType(); platformService = TypeMoq.Mock.ofType(); processService = TypeMoq.Mock.ofType(); - condaLocatorService = TypeMoq.Mock.ofType(); serviceContainer - .setup((c) => c.get(TypeMoq.It.isValue(ICondaLocatorService))) - .returns(() => condaLocatorService.object); + .setup((c) => c.get(TypeMoq.It.isValue(IComponentAdapter))) + .returns(() => componentAdapter.object); serviceContainer .setup((c) => c.get(TypeMoq.It.isValue(IExperimentService))) .returns(() => experimentService.object); @@ -98,9 +96,6 @@ suite('Terminal Environment Activation conda', () => { serviceContainer .setup((c) => c.get(TypeMoq.It.isValue(ICondaService), TypeMoq.It.isAny())) .returns(() => condaService.object); - serviceContainer - .setup((c) => c.get(TypeMoq.It.isValue(ICondaLocatorService))) - .returns(() => condaLocatorService.object); configService = TypeMoq.Mock.ofType(); serviceContainer @@ -122,8 +117,6 @@ suite('Terminal Environment Activation conda', () => { condaService.object, platformService.object, configService.object, - serviceContainer.object, - experimentService.object, componentAdapter.object, ), instance(bash), @@ -146,7 +139,7 @@ suite('Terminal Environment Activation conda', () => { const envName = 'EnvA'; const pythonPath = 'python3'; platformService.setup((p) => p.isWindows).returns(() => false); - condaLocatorService + componentAdapter .setup((c) => c.getCondaEnvironment(TypeMoq.It.isAny())) .returns(() => Promise.resolve({ name: envName, path: path.dirname(pythonPath) })); const expected = ['"path to conda" activate EnvA']; @@ -155,8 +148,6 @@ suite('Terminal Environment Activation conda', () => { condaService.object, platformService.object, configService.object, - serviceContainer.object, - experimentService.object, componentAdapter.object, ); const activationCommands = await provider.getActivationCommands(undefined, TerminalShellType.fish); @@ -170,7 +161,7 @@ suite('Terminal Environment Activation conda', () => { const condaPath = path.join('a', 'b', 'c', 'conda'); platformService.setup((p) => p.isWindows).returns(() => false); condaService.reset(); - condaLocatorService + componentAdapter .setup((c) => c.getCondaEnvironment(TypeMoq.It.isAny())) .returns(() => Promise.resolve({ @@ -186,8 +177,6 @@ suite('Terminal Environment Activation conda', () => { condaService.object, platformService.object, configService.object, - serviceContainer.object, - experimentService.object, componentAdapter.object, ); const activationCommands = await provider.getActivationCommands(undefined, TerminalShellType.bash); @@ -201,7 +190,7 @@ suite('Terminal Environment Activation conda', () => { const condaPath = path.join('a', 'b', 'c', 'conda'); platformService.setup((p) => p.isWindows).returns(() => false); condaService.reset(); - condaLocatorService + componentAdapter .setup((c) => c.getCondaEnvironment(TypeMoq.It.isAny())) .returns(() => Promise.resolve({ @@ -217,8 +206,6 @@ suite('Terminal Environment Activation conda', () => { condaService.object, platformService.object, configService.object, - serviceContainer.object, - experimentService.object, componentAdapter.object, ); const activationCommands = await provider.getActivationCommands(undefined, TerminalShellType.bash); @@ -279,7 +266,7 @@ suite('Terminal Environment Activation conda', () => { const pythonPath = 'python3'; platformService.setup((p) => p.isWindows).returns(() => testParams.isWindows); condaService.reset(); - condaLocatorService + componentAdapter .setup((c) => c.getCondaEnvironment(TypeMoq.It.isAny())) .returns(() => Promise.resolve({ @@ -296,8 +283,6 @@ suite('Terminal Environment Activation conda', () => { condaService.object, platformService.object, configService.object, - serviceContainer.object, - experimentService.object, componentAdapter.object, ); const activationCommands = await provider.getActivationCommands(undefined, TerminalShellType.bash); @@ -317,9 +302,9 @@ suite('Terminal Environment Activation conda', () => { platformService.setup((p) => p.isLinux).returns(() => isLinux); platformService.setup((p) => p.isWindows).returns(() => isWindows); platformService.setup((p) => p.isMac).returns(() => isOsx); - condaLocatorService.setup((c) => c.isCondaEnvironment(TypeMoq.It.isAny())).returns(() => Promise.resolve(true)); + componentAdapter.setup((c) => c.isCondaEnvironment(TypeMoq.It.isAny())).returns(() => Promise.resolve(true)); pythonSettings.setup((s) => s.pythonPath).returns(() => pythonPath); - condaLocatorService + componentAdapter .setup((c) => c.getCondaEnvironment(TypeMoq.It.isAny())) .returns(() => Promise.resolve({ name: envName, path: path.dirname(pythonPath) })); @@ -327,8 +312,6 @@ suite('Terminal Environment Activation conda', () => { condaService.object, platformService.object, configService.object, - serviceContainer.object, - experimentService.object, componentAdapter.object, ).getActivationCommands(undefined, shellType); let expectedActivationCommand: string[] | undefined; @@ -420,9 +403,9 @@ suite('Terminal Environment Activation conda', () => { platformService.setup((p) => p.isLinux).returns(() => isLinux); platformService.setup((p) => p.isWindows).returns(() => isWindows); platformService.setup((p) => p.isMac).returns(() => isOsx); - condaLocatorService.setup((c) => c.isCondaEnvironment(TypeMoq.It.isAny())).returns(() => Promise.resolve(true)); + componentAdapter.setup((c) => c.isCondaEnvironment(TypeMoq.It.isAny())).returns(() => Promise.resolve(true)); pythonSettings.setup((s) => s.pythonPath).returns(() => pythonPath); - condaLocatorService + componentAdapter .setup((c) => c.getCondaEnvironment(TypeMoq.It.isAny())) .returns(() => Promise.resolve({ name: 'EnvA', path: path.dirname(pythonPath) })); @@ -464,9 +447,7 @@ suite('Terminal Environment Activation conda', () => { test('Get activation script command if environment is not a conda environment', async () => { const pythonPath = path.join('users', 'xyz', '.conda', 'envs', 'enva', 'bin', 'python'); - condaLocatorService - .setup((c) => c.isCondaEnvironment(TypeMoq.It.isAny())) - .returns(() => Promise.resolve(false)); + componentAdapter.setup((c) => c.isCondaEnvironment(TypeMoq.It.isAny())).returns(() => Promise.resolve(false)); pythonSettings.setup((s) => s.pythonPath).returns(() => pythonPath); const mockProvider = TypeMoq.Mock.ofType(); @@ -498,10 +479,8 @@ suite('Terminal Environment Activation conda', () => { platformService.setup((p) => p.isLinux).returns(() => isLinux); platformService.setup((p) => p.isWindows).returns(() => isWindows); platformService.setup((p) => p.isMac).returns(() => isOsx); - condaLocatorService.setup((c) => c.isCondaEnvironment(TypeMoq.It.isAny())).returns(() => Promise.resolve(true)); - condaLocatorService - .setup((c) => c.isCondaEnvironment(TypeMoq.It.isAny())) - .returns(() => Promise.resolve(false)); + componentAdapter.setup((c) => c.isCondaEnvironment(TypeMoq.It.isAny())).returns(() => Promise.resolve(true)); + componentAdapter.setup((c) => c.isCondaEnvironment(TypeMoq.It.isAny())).returns(() => Promise.resolve(false)); pythonSettings.setup((s) => s.pythonPath).returns(() => pythonPath); when(bash.isShellSupported(anything())).thenReturn(true); @@ -546,9 +525,7 @@ suite('Terminal Environment Activation conda', () => { test('Return undefined if unable to get activation command', async () => { const pythonPath = path.join('c', 'users', 'xyz', '.conda', 'envs', 'enva', 'python.exe'); - condaLocatorService - .setup((c) => c.isCondaEnvironment(TypeMoq.It.isAny())) - .returns(() => Promise.resolve(false)); + componentAdapter.setup((c) => c.isCondaEnvironment(TypeMoq.It.isAny())).returns(() => Promise.resolve(false)); pythonSettings.setup((s) => s.pythonPath).returns(() => pythonPath); @@ -666,8 +643,6 @@ suite('Terminal Environment Activation conda', () => { condaSrv.object, platformService.object, configService.object, - serviceContainer.object, - experimentService.object, componentAdapter.object, ); diff --git a/src/test/common/terminals/environmentActivationProviders/pipEnvActivationProvider.unit.test.ts b/src/test/common/terminals/environmentActivationProviders/pipEnvActivationProvider.unit.test.ts index 89bc04005eab..3359bac89b06 100644 --- a/src/test/common/terminals/environmentActivationProviders/pipEnvActivationProvider.unit.test.ts +++ b/src/test/common/terminals/environmentActivationProviders/pipEnvActivationProvider.unit.test.ts @@ -9,12 +9,9 @@ import * as TypeMoq from 'typemoq'; import { Uri } from 'vscode'; import { IWorkspaceService } from '../../../../client/common/application/types'; import { WorkspaceService } from '../../../../client/common/application/workspace'; -import { DiscoveryVariants } from '../../../../client/common/experiments/groups'; -import { FileSystem } from '../../../../client/common/platform/fileSystem'; -import { IFileSystem } from '../../../../client/common/platform/types'; import { PipEnvActivationCommandProvider } from '../../../../client/common/terminal/environmentActivationProviders/pipEnvActivationProvider'; import { ITerminalActivationCommandProvider, TerminalShellType } from '../../../../client/common/terminal/types'; -import { IExperimentService, IToolExecutionPath } from '../../../../client/common/types'; +import { IToolExecutionPath } from '../../../../client/common/types'; import { getNamesAndValues } from '../../../../client/common/utils/enum'; import { IInterpreterService } from '../../../../client/interpreter/contracts'; import { InterpreterService } from '../../../../client/interpreter/interpreterService'; @@ -28,23 +25,15 @@ suite('Terminals Activation - Pipenv', () => { let interpreterService: IInterpreterService; let pipEnvExecution: TypeMoq.IMock; let workspaceService: IWorkspaceService; - let fs: IFileSystem; - let experimentService: IExperimentService; setup(() => { interpreterService = mock(InterpreterService); - fs = mock(FileSystem); workspaceService = mock(WorkspaceService); interpreterService = mock(InterpreterService); - experimentService = mock(); - when(experimentService.inExperiment(DiscoveryVariants.discoverWithFileWatching)).thenResolve(false); - when(experimentService.inExperiment(DiscoveryVariants.discoveryWithoutFileWatching)).thenResolve(false); pipEnvExecution = TypeMoq.Mock.ofType(); activationProvider = new PipEnvActivationCommandProvider( instance(interpreterService), pipEnvExecution.object, instance(workspaceService), - instance(fs), - instance(experimentService), ); pipEnvExecution.setup((p) => p.executable).returns(() => pipenvExecFile); diff --git a/src/test/common/terminals/helper.unit.test.ts b/src/test/common/terminals/helper.unit.test.ts index e2997b28bc44..ef688ac2257d 100644 --- a/src/test/common/terminals/helper.unit.test.ts +++ b/src/test/common/terminals/helper.unit.test.ts @@ -9,7 +9,6 @@ import { TerminalManager } from '../../../client/common/application/terminalMana import { ITerminalManager } from '../../../client/common/application/types'; import { PythonSettings } from '../../../client/common/configSettings'; import { ConfigurationService } from '../../../client/common/configuration/service'; -import { DiscoveryVariants } from '../../../client/common/experiments/groups'; import { PlatformService } from '../../../client/common/platform/platformService'; import { IPlatformService } from '../../../client/common/platform/types'; import { Bash } from '../../../client/common/terminal/environmentActivationProviders/bash'; @@ -25,10 +24,10 @@ import { ITerminalActivationCommandProvider, TerminalShellType, } from '../../../client/common/terminal/types'; -import { IConfigurationService, IExperimentService } from '../../../client/common/types'; +import { IConfigurationService } from '../../../client/common/types'; import { getNamesAndValues } from '../../../client/common/utils/enum'; import { Architecture, OSType } from '../../../client/common/utils/platform'; -import { ICondaLocatorService } from '../../../client/interpreter/contracts'; +import { IComponentAdapter } from '../../../client/interpreter/contracts'; import { InterpreterService } from '../../../client/interpreter/interpreterService'; import { IServiceContainer } from '../../../client/ioc/types'; import { EnvironmentType, PythonEnvironment } from '../../../client/pythonEnvironments/info'; @@ -37,8 +36,7 @@ suite('Terminal Service helpers', () => { let helper: TerminalHelper; let terminalManager: ITerminalManager; let platformService: IPlatformService; - let condaService: ICondaLocatorService; - let experimentService: IExperimentService; + let condaService: IComponentAdapter; let serviceContainer: IServiceContainer; let configurationService: IConfigurationService; let condaActivationProvider: ITerminalActivationCommandProvider; @@ -62,12 +60,9 @@ suite('Terminal Service helpers', () => { mockDetector = mock(TerminalNameShellDetector); terminalManager = mock(TerminalManager); platformService = mock(PlatformService); - experimentService = mock(); - when(experimentService.inExperiment(DiscoveryVariants.discoverWithFileWatching)).thenResolve(false); serviceContainer = mock(); - condaService = mock(); - when(serviceContainer.get(IExperimentService)).thenReturn(instance(experimentService)); - when(serviceContainer.get(ICondaLocatorService)).thenReturn(instance(condaService)); + condaService = mock(); + when(serviceContainer.get(IComponentAdapter)).thenReturn(instance(condaService)); configurationService = mock(ConfigurationService); condaActivationProvider = mock(CondaActivationCommandProvider); bashActivationProvider = mock(Bash); diff --git a/src/test/interpreters/display/progressDisplay.unit.test.ts b/src/test/interpreters/display/progressDisplay.unit.test.ts index db5b5cb0a52b..730f495e6f6a 100644 --- a/src/test/interpreters/display/progressDisplay.unit.test.ts +++ b/src/test/interpreters/display/progressDisplay.unit.test.ts @@ -7,13 +7,11 @@ import { expect } from 'chai'; import { anything, capture, instance, mock, when } from 'ts-mockito'; import { CancellationToken, Disposable, Progress, ProgressOptions } from 'vscode'; import { ApplicationShell } from '../../../client/common/application/applicationShell'; -import { ExperimentService } from '../../../client/common/experiments/service'; +import { createDeferred, Deferred } from '../../../client/common/utils/async'; import { Interpreters } from '../../../client/common/utils/localize'; -import { noop } from '../../../client/common/utils/misc'; -import { IComponentAdapter, IInterpreterLocatorProgressService } from '../../../client/interpreter/contracts'; +import { IComponentAdapter } from '../../../client/interpreter/contracts'; import { InterpreterLocatorProgressStatubarHandler } from '../../../client/interpreter/display/progressDisplay'; -import { ServiceContainer } from '../../../client/ioc/container'; -import { IServiceContainer } from '../../../client/ioc/types'; +import { noop } from '../../core'; type ProgressTask = ( progress: Progress<{ message?: string; increment?: number }>, @@ -22,38 +20,26 @@ type ProgressTask = ( suite('Interpreters - Display Progress', () => { let refreshingCallback: (e: void) => unknown | undefined; - let refreshedCallback: (e: void) => unknown | undefined; - const progressService: IInterpreterLocatorProgressService = { - onRefreshing(listener: (e: void) => unknown): Disposable { - refreshingCallback = listener; - return { dispose: noop }; - }, - onRefreshed(listener: (e: void) => unknown): Disposable { - refreshedCallback = listener; - return { dispose: noop }; - }, - activate(): Promise { - return Promise.resolve(); - }, - }; - let serviceContainer: IServiceContainer; - + let refreshDeferred: Deferred; + let componentAdapter: IComponentAdapter; setup(() => { - serviceContainer = mock(ServiceContainer); - when(serviceContainer.get(IInterpreterLocatorProgressService)).thenReturn( - progressService, - ); + refreshDeferred = createDeferred(); + componentAdapter = { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + onRefreshStart(listener: (e: void) => any): Disposable { + refreshingCallback = listener; + return { dispose: noop }; + }, + refreshPromise: refreshDeferred.promise, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + } as any; }); - - test('Display loading message when refreshing interpreters for the first time', async () => { + teardown(() => { + refreshDeferred.resolve(); + }); + test('Display discovering message when refreshing interpreters for the first time', async () => { const shell = mock(ApplicationShell); - const statusBar = new InterpreterLocatorProgressStatubarHandler( - instance(shell), - instance(serviceContainer), - [], - instance(mock(IComponentAdapter)), - instance(mock(ExperimentService)), - ); + const statusBar = new InterpreterLocatorProgressStatubarHandler(instance(shell), [], componentAdapter); when(shell.withProgress(anything(), anything())).thenResolve(); await statusBar.activate(); @@ -65,13 +51,7 @@ suite('Interpreters - Display Progress', () => { test('Display refreshing message when refreshing interpreters for the second time', async () => { const shell = mock(ApplicationShell); - const statusBar = new InterpreterLocatorProgressStatubarHandler( - instance(shell), - instance(serviceContainer), - [], - instance(mock(IComponentAdapter)), - instance(mock(ExperimentService)), - ); + const statusBar = new InterpreterLocatorProgressStatubarHandler(instance(shell), [], componentAdapter); when(shell.withProgress(anything(), anything())).thenResolve(); await statusBar.activate(); @@ -88,13 +68,7 @@ suite('Interpreters - Display Progress', () => { test('Progress message is hidden when loading has completed', async () => { const shell = mock(ApplicationShell); - const statusBar = new InterpreterLocatorProgressStatubarHandler( - instance(shell), - instance(serviceContainer), - [], - instance(mock(IComponentAdapter)), - instance(mock(ExperimentService)), - ); + const statusBar = new InterpreterLocatorProgressStatubarHandler(instance(shell), [], componentAdapter); when(shell.withProgress(anything(), anything())).thenResolve(); await statusBar.activate(); @@ -106,7 +80,7 @@ suite('Interpreters - Display Progress', () => { expect(options.title).to.be.equal(Interpreters.discovering()); - refreshedCallback(undefined); + refreshDeferred.resolve(); // Promise must resolve when refreshed callback is invoked. // When promise resolves, the progress message is hidden by VSC. await promise; diff --git a/src/test/interpreters/helpers.unit.test.ts b/src/test/interpreters/helpers.unit.test.ts index e932f71dfac3..3f64d5a26580 100644 --- a/src/test/interpreters/helpers.unit.test.ts +++ b/src/test/interpreters/helpers.unit.test.ts @@ -8,7 +8,6 @@ import { SemVer } from 'semver'; import * as TypeMoq from 'typemoq'; import { ConfigurationTarget, TextDocument, TextEditor, Uri } from 'vscode'; import { IDocumentManager, IWorkspaceService } from '../../client/common/application/types'; -import { IExperimentService } from '../../client/common/types'; import { IComponentAdapter } from '../../client/interpreter/contracts'; import { InterpreterHelper } from '../../client/interpreter/helpers'; import { IServiceContainer } from '../../client/ioc/types'; @@ -17,14 +16,12 @@ suite('Interpreters Display Helper', () => { let documentManager: TypeMoq.IMock; let workspaceService: TypeMoq.IMock; let serviceContainer: TypeMoq.IMock; - let experimentService: TypeMoq.IMock; let helper: InterpreterHelper; let pyenvs: TypeMoq.IMock; setup(() => { serviceContainer = TypeMoq.Mock.ofType(); workspaceService = TypeMoq.Mock.ofType(); documentManager = TypeMoq.Mock.ofType(); - experimentService = TypeMoq.Mock.ofType(); pyenvs = TypeMoq.Mock.ofType(); serviceContainer @@ -34,7 +31,7 @@ suite('Interpreters Display Helper', () => { .setup((c) => c.get(TypeMoq.It.isValue(IDocumentManager))) .returns(() => documentManager.object); - helper = new InterpreterHelper(serviceContainer.object, pyenvs.object, experimentService.object); + helper = new InterpreterHelper(serviceContainer.object, pyenvs.object); }); test('getActiveWorkspaceUri should return undefined if there are no workspaces', () => { workspaceService.setup((w) => w.workspaceFolders).returns(() => []); diff --git a/src/test/interpreters/virtualEnvs/virtualEnvPrompt.unit.test.ts b/src/test/interpreters/virtualEnvs/virtualEnvPrompt.unit.test.ts index f0529a81232e..45fd56f9d0c1 100644 --- a/src/test/interpreters/virtualEnvs/virtualEnvPrompt.unit.test.ts +++ b/src/test/interpreters/virtualEnvs/virtualEnvPrompt.unit.test.ts @@ -3,31 +3,19 @@ 'use strict'; -import { anything, deepEqual, instance, mock, reset, verify, when } from 'ts-mockito'; +import { anything, deepEqual, instance, mock, verify, when } from 'ts-mockito'; import * as TypeMoq from 'typemoq'; import { ConfigurationTarget, Disposable, Uri } from 'vscode'; import { ApplicationShell } from '../../../client/common/application/applicationShell'; import { IApplicationShell } from '../../../client/common/application/types'; -import { DiscoveryVariants } from '../../../client/common/experiments/groups'; -import { ExperimentService } from '../../../client/common/experiments/service'; import { PersistentStateFactory } from '../../../client/common/persistentState'; -import { IExperimentService, IPersistentState, IPersistentStateFactory } from '../../../client/common/types'; +import { IPersistentState, IPersistentStateFactory } from '../../../client/common/types'; import { Common } from '../../../client/common/utils/localize'; import { PythonPathUpdaterService } from '../../../client/interpreter/configuration/pythonPathUpdaterService'; import { IPythonPathUpdaterServiceManager } from '../../../client/interpreter/configuration/types'; -import { - IComponentAdapter, - IInterpreterHelper, - IInterpreterLocatorService, - IInterpreterWatcherBuilder, - WORKSPACE_VIRTUAL_ENV_SERVICE, -} from '../../../client/interpreter/contracts'; +import { IComponentAdapter, IInterpreterHelper } from '../../../client/interpreter/contracts'; import { InterpreterHelper } from '../../../client/interpreter/helpers'; import { VirtualEnvironmentPrompt } from '../../../client/interpreter/virtualEnvs/virtualEnvPrompt'; -import { ServiceContainer } from '../../../client/ioc/container'; -import { IServiceContainer } from '../../../client/ioc/types'; -import { CacheableLocatorService } from '../../../client/pythonEnvironments/discovery/locators/services/cacheableLocatorService'; -import { InterpreterWatcherBuilder } from '../../../client/pythonEnvironments/discovery/locators/services/interpreterWatcherBuilder'; import { PythonEnvironment } from '../../../client/pythonEnvironments/info'; suite('Virtual Environment Prompt', () => { @@ -40,44 +28,27 @@ suite('Virtual Environment Prompt', () => { await super.notifyUser(interpreter, resource); } } - let builder: IInterpreterWatcherBuilder; let persistentStateFactory: IPersistentStateFactory; let helper: IInterpreterHelper; let pythonPathUpdaterService: IPythonPathUpdaterServiceManager; - let locator: IInterpreterLocatorService; let disposable: Disposable; let appShell: IApplicationShell; - let serviceContainer: IServiceContainer; let componentAdapter: IComponentAdapter; - let experimentService: IExperimentService; let environmentPrompt: VirtualEnvironmentPromptTest; setup(() => { - builder = mock(InterpreterWatcherBuilder); - serviceContainer = mock(ServiceContainer); persistentStateFactory = mock(PersistentStateFactory); helper = mock(InterpreterHelper); - experimentService = mock(ExperimentService); pythonPathUpdaterService = mock(PythonPathUpdaterService); - locator = mock(CacheableLocatorService); componentAdapter = mock(); - when(experimentService.inExperiment(DiscoveryVariants.discoverWithFileWatching)).thenResolve(false); - when( - serviceContainer.get(IInterpreterLocatorService, WORKSPACE_VIRTUAL_ENV_SERVICE), - ).thenReturn(instance(locator)); - when(serviceContainer.get(IInterpreterWatcherBuilder)).thenReturn( - instance(builder), - ); disposable = mock(Disposable); appShell = mock(ApplicationShell); environmentPrompt = new VirtualEnvironmentPromptTest( - instance(serviceContainer), instance(persistentStateFactory), instance(helper), instance(pythonPathUpdaterService), [instance(disposable)], instance(appShell), instance(componentAdapter), - instance(experimentService), ); }); @@ -88,8 +59,11 @@ suite('Virtual Environment Prompt', () => { const prompts = [Common.bannerLabelYes(), Common.bannerLabelNo(), Common.doNotShowAgain()]; const notificationPromptEnabled = TypeMoq.Mock.ofType>(); - // eslint-disable-next-line @typescript-eslint/no-explicit-any - when(locator.getInterpreters(resource)).thenResolve([interpreter1, interpreter2] as any); + when(componentAdapter.getWorkspaceVirtualEnvInterpreters(resource)).thenResolve([ + interpreter1, + interpreter2, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + ] as any); // eslint-disable-next-line @typescript-eslint/no-explicit-any when(helper.getBestInterpreter(deepEqual([interpreter1, interpreter2] as any))).thenReturn(interpreter2 as any); when(persistentStateFactory.createWorkspacePersistentState(anything(), true)).thenReturn( @@ -105,8 +79,6 @@ suite('Virtual Environment Prompt', () => { test('When in experiment, user is notified if interpreter exists and only python path to global interpreter is specified in settings', async () => { const resource = Uri.file('a'); - reset(experimentService); - when(experimentService.inExperiment(DiscoveryVariants.discoverWithFileWatching)).thenResolve(true); const interpreter1 = { path: 'path/to/interpreter1' }; const interpreter2 = { path: 'path/to/interpreter2' }; const prompts = [Common.bannerLabelYes(), Common.bannerLabelNo(), Common.doNotShowAgain()]; diff --git a/src/test/linters/lint.functional.test.ts b/src/test/linters/lint.functional.test.ts index b06fbae4e803..fd083214d8fe 100644 --- a/src/test/linters/lint.functional.test.ts +++ b/src/test/linters/lint.functional.test.ts @@ -45,7 +45,6 @@ import { LINTERID_BY_PRODUCT } from '../../client/linters/constants'; import { ILintMessage, LinterId, LintMessageSeverity } from '../../client/linters/types'; import { deleteFile, PYTHON_PATH } from '../common'; import { BaseTestFixture, getLinterID, getProductName, newMockDocument, throwUnknownProduct } from './common'; -import * as ExperimentHelpers from '../../client/common/experiments/helpers'; import { DiscoveryVariants } from '../../client/common/experiments/groups'; import { IInterpreterAutoSelectionService } from '../../client/interpreter/autoSelection/types'; @@ -738,9 +737,6 @@ class TestFixture extends BaseTestFixture { .setup((e) => e.inExperiment(DiscoveryVariants.discoverWithFileWatching)) .returns(() => Promise.resolve(false)); - const inDiscoveryExperimentStub = sinon.stub(ExperimentHelpers, 'inDiscoveryExperiment'); - inDiscoveryExperimentStub.resolves(false); - const autoSelection = mock(); const interpreterPathExpHelper = mock(); when(interpreterPathExpHelper.get(anything())).thenReturn('selected interpreter path'); @@ -753,7 +749,6 @@ class TestFixture extends BaseTestFixture { condaService.object, decoder, instance(pyenvs), - experimentService.object, instance(autoSelection), instance(interpreterPathExpHelper), ); diff --git a/src/test/pythonEnvironments/discovery/locators/condaLocatorService.unit.test.ts b/src/test/pythonEnvironments/discovery/locators/condaLocatorService.unit.test.ts index bbe38c0f7679..4cc52b9e2b29 100644 --- a/src/test/pythonEnvironments/discovery/locators/condaLocatorService.unit.test.ts +++ b/src/test/pythonEnvironments/discovery/locators/condaLocatorService.unit.test.ts @@ -10,20 +10,13 @@ import * as TypeMoq from 'typemoq'; import { Disposable, EventEmitter } from 'vscode'; import { IWorkspaceService } from '../../../../client/common/application/types'; -import { DiscoveryVariants } from '../../../../client/common/experiments/groups'; import { FileSystemPaths, FileSystemPathUtils } from '../../../../client/common/platform/fs-paths'; import { IFileSystem, IPlatformService } from '../../../../client/common/platform/types'; import { IProcessService, IProcessServiceFactory } from '../../../../client/common/process/types'; import { ITerminalActivationCommandProvider } from '../../../../client/common/terminal/types'; -import { - IConfigurationService, - IExperimentService, - IPersistentStateFactory, - IPythonSettings, -} from '../../../../client/common/types'; +import { IConfigurationService, IPersistentStateFactory, IPythonSettings } from '../../../../client/common/types'; import { Architecture } from '../../../../client/common/utils/platform'; import { - IComponentAdapter, IInterpreterLocatorService, IInterpreterService, WINDOWS_REGISTRY_SERVICE, @@ -52,7 +45,6 @@ suite('Interpreters Conda Service', () => { let processService: TypeMoq.IMock; let platformService: TypeMoq.IMock; let condaService: CondaLocatorService; - let pyenvs: TypeMoq.IMock; let fileSystem: TypeMoq.IMock; let config: TypeMoq.IMock; let settings: TypeMoq.IMock; @@ -66,7 +58,6 @@ suite('Interpreters Conda Service', () => { let workspaceService: TypeMoq.IMock; let mockState: MockState; let terminalProvider: TypeMoq.IMock; - let experimentService: TypeMoq.IMock; setup(async () => { condaPathSetting = ''; processService = TypeMoq.Mock.ofType(); @@ -74,7 +65,6 @@ suite('Interpreters Conda Service', () => { persistentStateFactory = TypeMoq.Mock.ofType(); interpreterService = TypeMoq.Mock.ofType(); registryInterpreterLocatorService = TypeMoq.Mock.ofType(); - pyenvs = TypeMoq.Mock.ofType(); fileSystem = TypeMoq.Mock.ofType(); workspaceService = TypeMoq.Mock.ofType(); config = TypeMoq.Mock.ofType(); @@ -102,14 +92,6 @@ suite('Interpreters Conda Service', () => { .setup((p) => p.getActivationCommandsForInterpreter!(TypeMoq.It.isAny(), TypeMoq.It.isAny())) .returns(() => Promise.resolve(['activate'])); - experimentService = TypeMoq.Mock.ofType(); - experimentService - .setup((exp) => exp.inExperiment(DiscoveryVariants.discoverWithFileWatching)) - .returns(() => Promise.resolve(false)); - experimentService - .setup((exp) => exp.inExperiment(DiscoveryVariants.discoveryWithoutFileWatching)) - .returns(() => Promise.resolve(false)); - serviceContainer = TypeMoq.Mock.ofType(); serviceContainer .setup((c) => c.get(TypeMoq.It.isValue(IProcessServiceFactory), TypeMoq.It.isAny())) @@ -153,8 +135,6 @@ suite('Interpreters Conda Service', () => { config.object, disposableRegistry, workspaceService.object, - pyenvs.object, - experimentService.object, serviceContainer.object, ); }); @@ -657,8 +637,6 @@ suite('Interpreters Conda Service', () => { config.object, disposableRegistry, workspaceService.object, - pyenvs.object, - experimentService.object, serviceContainer.object, ); diff --git a/src/test/pythonEnvironments/discovery/locators/condaService.unit.test.ts b/src/test/pythonEnvironments/discovery/locators/condaService.unit.test.ts index c06a69eb65ff..afeac855644a 100644 --- a/src/test/pythonEnvironments/discovery/locators/condaService.unit.test.ts +++ b/src/test/pythonEnvironments/discovery/locators/condaService.unit.test.ts @@ -3,13 +3,10 @@ import * as path from 'path'; import { parse } from 'semver'; import * as TypeMoq from 'typemoq'; import { IWorkspaceService } from '../../../../client/common/application/types'; - -import { DiscoveryVariants } from '../../../../client/common/experiments/groups'; import { FileSystemPaths, FileSystemPathUtils } from '../../../../client/common/platform/fs-paths'; import { IFileSystem, IPlatformService } from '../../../../client/common/platform/types'; import { IProcessService, IProcessServiceFactory } from '../../../../client/common/process/types'; -import { IConfigurationService, IExperimentService, IPythonSettings } from '../../../../client/common/types'; -import { IServiceContainer } from '../../../../client/ioc/types'; +import { IConfigurationService, IPythonSettings } from '../../../../client/common/types'; import { CondaService } from '../../../../client/pythonEnvironments/discovery/locators/services/condaService'; suite('Interpreters Conda Service', () => { @@ -19,10 +16,8 @@ suite('Interpreters Conda Service', () => { let fileSystem: TypeMoq.IMock; let config: TypeMoq.IMock; let settings: TypeMoq.IMock; - let serviceContainer: TypeMoq.IMock; let procServiceFactory: TypeMoq.IMock; let condaPathSetting: string; - let experimentService: TypeMoq.IMock; let workspaceService: TypeMoq.IMock; setup(async () => { condaPathSetting = ''; @@ -39,27 +34,6 @@ suite('Interpreters Conda Service', () => { .setup((p) => p.create(TypeMoq.It.isAny())) .returns(() => Promise.resolve(processService.object)); - experimentService = TypeMoq.Mock.ofType(); - experimentService - .setup((exp) => exp.inExperiment(DiscoveryVariants.discoverWithFileWatching)) - .returns(() => Promise.resolve(false)); - experimentService - .setup((exp) => exp.inExperiment(DiscoveryVariants.discoveryWithoutFileWatching)) - .returns(() => Promise.resolve(false)); - - serviceContainer = TypeMoq.Mock.ofType(); - serviceContainer - .setup((c) => c.get(TypeMoq.It.isValue(IProcessServiceFactory), TypeMoq.It.isAny())) - .returns(() => procServiceFactory.object); - serviceContainer - .setup((c) => c.get(TypeMoq.It.isValue(IPlatformService), TypeMoq.It.isAny())) - .returns(() => platformService.object); - serviceContainer - .setup((c) => c.get(TypeMoq.It.isValue(IFileSystem), TypeMoq.It.isAny())) - .returns(() => fileSystem.object); - serviceContainer - .setup((c) => c.get(TypeMoq.It.isValue(IConfigurationService), TypeMoq.It.isAny())) - .returns(() => config.object); config.setup((c) => c.getSettings(TypeMoq.It.isValue(undefined))).returns(() => settings.object); settings.setup((p) => p.condaPath).returns(() => condaPathSetting); fileSystem @@ -75,8 +49,6 @@ suite('Interpreters Conda Service', () => { procServiceFactory.object, platformService.object, fileSystem.object, - serviceContainer.object, - experimentService.object, config.object, [], workspaceService.object, diff --git a/src/test/tensorBoard/tensorBoardSession.test.ts b/src/test/tensorBoard/tensorBoardSession.test.ts index 23c10a91aef9..7d8fd08911bf 100644 --- a/src/test/tensorBoard/tensorBoardSession.test.ts +++ b/src/test/tensorBoard/tensorBoardSession.test.ts @@ -16,7 +16,6 @@ import { IServiceManager } from '../../client/ioc/types'; import { TensorBoardEntrypoint, TensorBoardEntrypointTrigger } from '../../client/tensorBoard/constants'; import { TensorBoardSession } from '../../client/tensorBoard/tensorBoardSession'; import { closeActiveWindows, EXTENSION_ROOT_DIR_FOR_TESTS, initialize } from '../initialize'; -import * as ExperimentHelpers from '../../client/common/experiments/helpers'; import { IInterpreterService } from '../../client/interpreter/contracts'; import { Architecture } from '../../client/common/utils/platform'; import { PythonEnvironment, EnvironmentType } from '../../client/pythonEnvironments/info'; @@ -70,9 +69,8 @@ suite('TensorBoard session creation', async () => { setup(async () => { sandbox = sinon.createSandbox(); ({ serviceManager } = await initialize()); - sandbox.stub(ExperimentHelpers, 'inDiscoveryExperiment').resolves(true); - experimentService = serviceManager.get(IExperimentService); + experimentService = serviceManager.get(IExperimentService); const interpreterService = serviceManager.get(IInterpreterService); sandbox.stub(interpreterService, 'getActiveInterpreter').resolves(interpreter);