Skip to content

Commit

Permalink
Remove old discovery code and discovery experiments (#17795)
Browse files Browse the repository at this point in the history
* Remove code

* Lint

* Fix unit tests

* Remove discovery experiments

* Oops

* Update settings.json

* News entry

* Disable windows store watcher tests

* Disable global watchers

* Remove Interpereter version service

* Conda service is no longer legacy IOC

* Move conda service to correct module
  • Loading branch information
Kartik Raj authored Oct 20, 2021
1 parent 7f9b6e0 commit ff6a026
Show file tree
Hide file tree
Showing 89 changed files with 99 additions and 9,635 deletions.
6 changes: 0 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,6 @@ jobs:
& $condaPythonPath ./build/ci/addEnvPath.py ${{ env.PYTHON_VIRTUAL_ENVS_LOCATION }} condaPath
& $condaExecPath init --all
# 2. For `interpreterLocatorService.testvirtualenvs.ts`
& $condaExecPath create -n "test_env1" -y python
& $condaExecPath create -p "./test_env2" -y python
& $condaExecPath create -p "~/test_env3" -y python
- name: Set CI_PYTHON_PATH and CI_DISABLE_AUTO_SELECTION
run: |
echo "CI_PYTHON_PATH=python" >> $GITHUB_ENV
Expand Down
12 changes: 0 additions & 12 deletions .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,6 @@ jobs:
& $condaPythonPath ./build/ci/addEnvPath.py ${{ env.PYTHON_VIRTUAL_ENVS_LOCATION }} condaPath
& $condaExecPath init --all
# 2. For `interpreterLocatorService.testvirtualenvs.ts`
& $condaExecPath create -n "test_env1" -y python
& $condaExecPath create -p "./test_env2" -y python
& $condaExecPath create -p "~/test_env3" -y python
- name: Set CI_PYTHON_PATH and CI_DISABLE_AUTO_SELECTION
run: |
echo "CI_PYTHON_PATH=python" >> $GITHUB_ENV
Expand Down Expand Up @@ -458,12 +452,6 @@ jobs:
& $condaPythonPath ./build/ci/addEnvPath.py ${{ env.PYTHON_VIRTUAL_ENVS_LOCATION }} condaPath
& $condaExecPath init --all
# 2. For `interpreterLocatorService.testvirtualenvs.ts`
& $condaExecPath create -n "test_env1" -y python
& $condaExecPath create -p "./test_env2" -y python
& $condaExecPath create -p "~/test_env3" -y python
- name: Run TypeScript unit tests
run: npm run test:unittests:cover

Expand Down
1 change: 1 addition & 0 deletions news/3 Code Health/17795.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove old discovery code and discovery experiments.
4 changes: 0 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -616,8 +616,6 @@
"enum": [
"All",
"pythonDeprecatePythonPath",
"pythonDiscoveryModule",
"pythonDiscoveryModuleWithoutWatcher",
"pythonSurveyNotification",
"pythonTensorboardExperiment",
"pythonRunFailedTestsButtonDisplayed",
Expand All @@ -635,8 +633,6 @@
"enum": [
"All",
"pythonDeprecatePythonPath",
"pythonDiscoveryModule",
"pythonDiscoveryModuleWithoutWatcher",
"pythonSurveyNotification",
"pythonTensorboardExperiment",
"pythonRunFailedTestsButtonDisplayed",
Expand Down
6 changes: 0 additions & 6 deletions src/client/common/experiments/groups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@ export enum NativeTensorBoard {
experiment = 'pythonTensorboardExperiment',
}

// Experiment to control which environment discovery mechanism can be used
export enum DiscoveryVariants {
discoverWithFileWatching = 'pythonDiscoveryModule',
discoveryWithoutFileWatching = 'pythonDiscoveryModuleWithoutWatcher',
}

// Feature gate to control whether we install the PyTorch profiler package
// torch.profiler release is being delayed till end of March. This allows us
// to turn on the profiler plugin install functionality between releases
Expand Down
6 changes: 0 additions & 6 deletions src/client/common/experiments/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { IApplicationEnvironment, IWorkspaceService } from '../application/types
import { PVSC_EXTENSION_ID, STANDARD_OUTPUT_CHANNEL } from '../constants';
import { GLOBAL_MEMENTO, IExperimentService, IMemento, IOutputChannel } from '../types';
import { Experiments } from '../utils/localize';
import { DiscoveryVariants } from './groups';
import { ExperimentationTelemetry } from './telemetry';

const EXP_MEMENTO_KEY = 'VSCode.ABExp.FeatureData';
Expand Down Expand Up @@ -109,11 +108,6 @@ export class ExperimentService implements IExperimentService {
}

public inExperimentSync(experiment: string): boolean {
if (experiment === DiscoveryVariants.discoveryWithoutFileWatching) {
// Enable discovery experiment for all users.
return true;
}

if (!this.experimentationService) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,44 @@ import { inject, injectable } from 'inversify';
import * as path from 'path';
import { Uri } from 'vscode';
import { IServiceContainer } from '../../../ioc/types';
import { getVenvExecutableFinder } from '../../../pythonEnvironments/discovery/subenv';
import { IFileSystem } from '../../platform/types';
import { IConfigurationService } from '../../types';
import { ITerminalActivationCommandProvider, TerminalShellType } from '../types';

type ExecutableFinderFunc = (python: string) => Promise<string | undefined>;

/**
* Build an "executable finder" function that identifies venv environments.
*
* @param basename - the venv name or names to look for
* @param pathDirname - typically `path.dirname`
* @param pathJoin - typically `path.join`
* @param fileExists - typically `fs.exists`
*/

function getVenvExecutableFinder(
basename: string | string[],
// <path>
pathDirname: (filename: string) => string,
pathJoin: (...parts: string[]) => string,
// </path>
fileExists: (n: string) => Promise<boolean>,
): ExecutableFinderFunc {
const basenames = typeof basename === 'string' ? [basename] : basename;
return async (python: string) => {
// Generated scripts are found in the same directory as the interpreter.
const binDir = pathDirname(python);
for (const name of basenames) {
const filename = pathJoin(binDir, name);
if (await fileExists(filename)) {
return filename;
}
}
// No matches so return undefined.
return undefined;
};
}

@injectable()
abstract class BaseActivationCommandProvider implements ITerminalActivationCommandProvider {
constructor(@inject(IServiceContainer) protected readonly serviceContainer: IServiceContainer) {}
Expand Down
81 changes: 2 additions & 79 deletions src/client/interpreter/contracts.ts
Original file line number Diff line number Diff line change
@@ -1,37 +1,12 @@
import { SemVer } from 'semver';
import { CodeLensProvider, ConfigurationTarget, Disposable, Event, TextDocument, Uri } from 'vscode';
import { IExtensionSingleActivationService } from '../activation/types';
import { FileChangeType } from '../common/platform/fileSystemWatcher';
import { Resource } from '../common/types';
import { PythonEnvSource } from '../pythonEnvironments/base/info';
import { PythonLocatorQuery } from '../pythonEnvironments/base/locator';
import { CondaEnvironmentInfo, CondaInfo } from '../pythonEnvironments/common/environmentManagers/conda';
import { CondaEnvironmentInfo } from '../pythonEnvironments/common/environmentManagers/conda';
import { EnvironmentType, PythonEnvironment } from '../pythonEnvironments/info';

export const INTERPRETER_LOCATOR_SERVICE = 'IInterpreterLocatorService';
export const WINDOWS_REGISTRY_SERVICE = 'WindowsRegistryService';
export const CONDA_ENV_FILE_SERVICE = 'CondaEnvFileService';
export const CONDA_ENV_SERVICE = 'CondaEnvService';
export const CURRENT_PATH_SERVICE = 'CurrentPathService';
export const KNOWN_PATH_SERVICE = 'KnownPathsService';
export const GLOBAL_VIRTUAL_ENV_SERVICE = 'VirtualEnvService';
export const WORKSPACE_VIRTUAL_ENV_SERVICE = 'WorkspaceVirtualEnvService';
export const PIPENV_SERVICE = 'PipEnvService';
export const IInterpreterVersionService = Symbol('IInterpreterVersionService');
export interface IInterpreterVersionService {
getVersion(pythonPath: string, defaultValue: string): Promise<string>;
getPipVersion(pythonPath: string): Promise<string>;
}

export const IKnownSearchPathsForInterpreters = Symbol('IKnownSearchPathsForInterpreters');
export interface IKnownSearchPathsForInterpreters {
getSearchPaths(): string[];
}
export const IVirtualEnvironmentsSearchPathProvider = Symbol('IVirtualEnvironmentsSearchPathProvider');
export interface IVirtualEnvironmentsSearchPathProvider {
getSearchPaths(resource?: Uri): Promise<string[]>;
}

export type PythonEnvironmentsChangedEvent = {
type?: FileChangeType;
resource?: Uri;
Expand Down Expand Up @@ -74,15 +49,6 @@ export interface IComponentAdapter {
isWindowsStoreInterpreter(pythonPath: string): Promise<boolean>;
}

export const IInterpreterLocatorService = Symbol('IInterpreterLocatorService');

export interface IInterpreterLocatorService extends Disposable {
readonly onLocating: Event<Promise<PythonEnvironment[]>>;
readonly hasInterpreters: Promise<boolean>;
didTriggerInterpreterSuggestions?: boolean;
getInterpreters(resource?: Uri, options?: GetInterpreterOptions): Promise<PythonEnvironment[]>;
}

export const ICondaService = Symbol('ICondaService');
/**
* Interface carries the properties which are not available via the discovery component interface.
Expand All @@ -94,20 +60,6 @@ export interface ICondaService {
getCondaFileFromInterpreter(interpreterPath?: string, envName?: string): Promise<string | undefined>;
}

export const ICondaLocatorService = Symbol('ICondaLocatorService');
/**
* @deprecated Use the new discovery component when in experiment, use this otherwise.
*/
export interface ICondaLocatorService {
readonly condaEnvironmentsFile: string | undefined;
getCondaFile(): Promise<string>;
getCondaInfo(): Promise<CondaInfo | undefined>;
getCondaEnvironments(ignoreCache: boolean): Promise<CondaEnvironmentInfo[] | undefined>;
getInterpreterPath(condaEnvironmentPath: string): string;
isCondaEnvironment(interpreterPath: string): Promise<boolean>;
getCondaEnvironment(interpreterPath: string): Promise<CondaEnvironmentInfo | undefined>;
}

export const IInterpreterService = Symbol('IInterpreterService');
export interface IInterpreterService {
readonly onRefreshStart: Event<void>;
Expand All @@ -119,7 +71,7 @@ export interface IInterpreterService {
onDidChangeInterpreterInformation: Event<PythonEnvironment>;
hasInterpreters(filter?: (e: PythonEnvironment) => Promise<boolean>): Promise<boolean>;
getInterpreters(resource?: Uri): PythonEnvironment[];
getAllInterpreters(resource?: Uri, options?: GetInterpreterOptions): Promise<PythonEnvironment[]>;
getAllInterpreters(resource?: Uri): Promise<PythonEnvironment[]>;
getActiveInterpreter(resource?: Uri): Promise<PythonEnvironment | undefined>;
getInterpreterDetails(pythonPath: string, resoure?: Uri): Promise<undefined | PythonEnvironment>;
refresh(resource: Resource): Promise<void>;
Expand All @@ -146,33 +98,6 @@ export interface IInterpreterHelper {
getBestInterpreter(interpreters?: PythonEnvironment[]): PythonEnvironment | undefined;
}

export const IPipEnvService = Symbol('IPipEnvService');
export interface IPipEnvService extends IInterpreterLocatorService {
executable: string;
isRelatedPipEnvironment(dir: string, pythonPath: string): Promise<boolean>;
}

export const IInterpreterLocatorHelper = Symbol('IInterpreterLocatorHelper');
export interface IInterpreterLocatorHelper {
mergeInterpreters(interpreters: PythonEnvironment[]): Promise<PythonEnvironment[]>;
}

export const IInterpreterWatcher = Symbol('IInterpreterWatcher');
export interface IInterpreterWatcher {
onDidCreate: Event<Resource>;
}

export const IInterpreterWatcherBuilder = Symbol('IInterpreterWatcherBuilder');
export interface IInterpreterWatcherBuilder {
getWorkspaceVirtualEnvInterpreterWatcher(resource: Resource): Promise<IInterpreterWatcher>;
}

export const IInterpreterLocatorProgressService = Symbol('IInterpreterLocatorProgressService');
export interface IInterpreterLocatorProgressService extends IExtensionSingleActivationService {
readonly onRefreshing: Event<void>;
readonly onRefreshed: Event<void>;
}

export const IInterpreterStatusbarVisibilityFilter = Symbol('IInterpreterStatusbarVisibilityFilter');
/**
* Implement this interface to control the visibility of the interpreter statusbar.
Expand All @@ -186,5 +111,3 @@ export type WorkspacePythonPath = {
folderUri: Uri;
configTarget: ConfigurationTarget.Workspace | ConfigurationTarget.WorkspaceFolder;
};

export type GetInterpreterOptions = { ignoreCache?: boolean; onSuggestion?: boolean };
37 changes: 0 additions & 37 deletions src/client/interpreter/interpreterVersion.ts

This file was deleted.

11 changes: 1 addition & 10 deletions src/client/interpreter/serviceRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,12 @@ import {
IPythonPathUpdaterServiceFactory,
IPythonPathUpdaterServiceManager,
} from './configuration/types';
import {
IInterpreterDisplay,
IInterpreterHelper,
IInterpreterService,
IInterpreterVersionService,
IShebangCodeLensProvider,
} from './contracts';
import { IInterpreterDisplay, IInterpreterHelper, IInterpreterService, IShebangCodeLensProvider } from './contracts';
import { InterpreterDisplay } from './display';
import { InterpreterLocatorProgressStatubarHandler } from './display/progressDisplay';
import { ShebangCodeLensProvider } from './display/shebangCodeLensProvider';
import { InterpreterHelper } from './helpers';
import { InterpreterService } from './interpreterService';
import { InterpreterVersionService } from './interpreterVersion';
import { CondaInheritEnvPrompt } from './virtualEnvs/condaInheritEnvPrompt';
import { VirtualEnvironmentPrompt } from './virtualEnvs/virtualEnvPrompt';

Expand All @@ -62,8 +55,6 @@ export function registerInterpreterTypes(serviceManager: IServiceManager): void

serviceManager.addSingleton<IExtensionActivationService>(IExtensionActivationService, VirtualEnvironmentPrompt);

serviceManager.addSingleton<IInterpreterVersionService>(IInterpreterVersionService, InterpreterVersionService);

serviceManager.addSingleton<IInterpreterService>(IInterpreterService, InterpreterService);
serviceManager.addSingleton<IInterpreterDisplay>(IInterpreterDisplay, InterpreterDisplay);

Expand Down
Loading

0 comments on commit ff6a026

Please sign in to comment.