Skip to content

Commit ebd9fb6

Browse files
Kartik Rajwesm
Kartik Raj
authored andcommitted
Remove old discovery code and discovery experiments (microsoft/vscode-python#17795)
* 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
1 parent 8f4d671 commit ebd9fb6

File tree

89 files changed

+99
-9635
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+99
-9635
lines changed

extensions/positron-python/.github/workflows/build.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -211,12 +211,6 @@ jobs:
211211
& $condaPythonPath ./build/ci/addEnvPath.py ${{ env.PYTHON_VIRTUAL_ENVS_LOCATION }} condaPath
212212
& $condaExecPath init --all
213213
214-
# 2. For `interpreterLocatorService.testvirtualenvs.ts`
215-
216-
& $condaExecPath create -n "test_env1" -y python
217-
& $condaExecPath create -p "./test_env2" -y python
218-
& $condaExecPath create -p "~/test_env3" -y python
219-
220214
- name: Set CI_PYTHON_PATH and CI_DISABLE_AUTO_SELECTION
221215
run: |
222216
echo "CI_PYTHON_PATH=python" >> $GITHUB_ENV

extensions/positron-python/.github/workflows/pr-check.yml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,6 @@ jobs:
191191
& $condaPythonPath ./build/ci/addEnvPath.py ${{ env.PYTHON_VIRTUAL_ENVS_LOCATION }} condaPath
192192
& $condaExecPath init --all
193193
194-
# 2. For `interpreterLocatorService.testvirtualenvs.ts`
195-
196-
& $condaExecPath create -n "test_env1" -y python
197-
& $condaExecPath create -p "./test_env2" -y python
198-
& $condaExecPath create -p "~/test_env3" -y python
199-
200194
- name: Set CI_PYTHON_PATH and CI_DISABLE_AUTO_SELECTION
201195
run: |
202196
echo "CI_PYTHON_PATH=python" >> $GITHUB_ENV
@@ -458,12 +452,6 @@ jobs:
458452
& $condaPythonPath ./build/ci/addEnvPath.py ${{ env.PYTHON_VIRTUAL_ENVS_LOCATION }} condaPath
459453
& $condaExecPath init --all
460454
461-
# 2. For `interpreterLocatorService.testvirtualenvs.ts`
462-
463-
& $condaExecPath create -n "test_env1" -y python
464-
& $condaExecPath create -p "./test_env2" -y python
465-
& $condaExecPath create -p "~/test_env3" -y python
466-
467455
- name: Run TypeScript unit tests
468456
run: npm run test:unittests:cover
469457

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Remove old discovery code and discovery experiments.

extensions/positron-python/package.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -616,8 +616,6 @@
616616
"enum": [
617617
"All",
618618
"pythonDeprecatePythonPath",
619-
"pythonDiscoveryModule",
620-
"pythonDiscoveryModuleWithoutWatcher",
621619
"pythonSurveyNotification",
622620
"pythonTensorboardExperiment",
623621
"pythonRunFailedTestsButtonDisplayed",
@@ -635,8 +633,6 @@
635633
"enum": [
636634
"All",
637635
"pythonDeprecatePythonPath",
638-
"pythonDiscoveryModule",
639-
"pythonDiscoveryModuleWithoutWatcher",
640636
"pythonSurveyNotification",
641637
"pythonTensorboardExperiment",
642638
"pythonRunFailedTestsButtonDisplayed",

extensions/positron-python/src/client/common/experiments/groups.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,6 @@ export enum NativeTensorBoard {
2222
experiment = 'pythonTensorboardExperiment',
2323
}
2424

25-
// Experiment to control which environment discovery mechanism can be used
26-
export enum DiscoveryVariants {
27-
discoverWithFileWatching = 'pythonDiscoveryModule',
28-
discoveryWithoutFileWatching = 'pythonDiscoveryModuleWithoutWatcher',
29-
}
30-
3125
// Feature gate to control whether we install the PyTorch profiler package
3226
// torch.profiler release is being delayed till end of March. This allows us
3327
// to turn on the profiler plugin install functionality between releases

extensions/positron-python/src/client/common/experiments/service.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import { IApplicationEnvironment, IWorkspaceService } from '../application/types
1212
import { PVSC_EXTENSION_ID, STANDARD_OUTPUT_CHANNEL } from '../constants';
1313
import { GLOBAL_MEMENTO, IExperimentService, IMemento, IOutputChannel } from '../types';
1414
import { Experiments } from '../utils/localize';
15-
import { DiscoveryVariants } from './groups';
1615
import { ExperimentationTelemetry } from './telemetry';
1716

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

111110
public inExperimentSync(experiment: string): boolean {
112-
if (experiment === DiscoveryVariants.discoveryWithoutFileWatching) {
113-
// Enable discovery experiment for all users.
114-
return true;
115-
}
116-
117111
if (!this.experimentationService) {
118112
return false;
119113
}

extensions/positron-python/src/client/common/terminal/environmentActivationProviders/baseActivationProvider.ts

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,44 @@ import { inject, injectable } from 'inversify';
55
import * as path from 'path';
66
import { Uri } from 'vscode';
77
import { IServiceContainer } from '../../../ioc/types';
8-
import { getVenvExecutableFinder } from '../../../pythonEnvironments/discovery/subenv';
98
import { IFileSystem } from '../../platform/types';
109
import { IConfigurationService } from '../../types';
1110
import { ITerminalActivationCommandProvider, TerminalShellType } from '../types';
1211

12+
type ExecutableFinderFunc = (python: string) => Promise<string | undefined>;
13+
14+
/**
15+
* Build an "executable finder" function that identifies venv environments.
16+
*
17+
* @param basename - the venv name or names to look for
18+
* @param pathDirname - typically `path.dirname`
19+
* @param pathJoin - typically `path.join`
20+
* @param fileExists - typically `fs.exists`
21+
*/
22+
23+
function getVenvExecutableFinder(
24+
basename: string | string[],
25+
// <path>
26+
pathDirname: (filename: string) => string,
27+
pathJoin: (...parts: string[]) => string,
28+
// </path>
29+
fileExists: (n: string) => Promise<boolean>,
30+
): ExecutableFinderFunc {
31+
const basenames = typeof basename === 'string' ? [basename] : basename;
32+
return async (python: string) => {
33+
// Generated scripts are found in the same directory as the interpreter.
34+
const binDir = pathDirname(python);
35+
for (const name of basenames) {
36+
const filename = pathJoin(binDir, name);
37+
if (await fileExists(filename)) {
38+
return filename;
39+
}
40+
}
41+
// No matches so return undefined.
42+
return undefined;
43+
};
44+
}
45+
1346
@injectable()
1447
abstract class BaseActivationCommandProvider implements ITerminalActivationCommandProvider {
1548
constructor(@inject(IServiceContainer) protected readonly serviceContainer: IServiceContainer) {}
Lines changed: 2 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,12 @@
11
import { SemVer } from 'semver';
22
import { CodeLensProvider, ConfigurationTarget, Disposable, Event, TextDocument, Uri } from 'vscode';
3-
import { IExtensionSingleActivationService } from '../activation/types';
43
import { FileChangeType } from '../common/platform/fileSystemWatcher';
54
import { Resource } from '../common/types';
65
import { PythonEnvSource } from '../pythonEnvironments/base/info';
76
import { PythonLocatorQuery } from '../pythonEnvironments/base/locator';
8-
import { CondaEnvironmentInfo, CondaInfo } from '../pythonEnvironments/common/environmentManagers/conda';
7+
import { CondaEnvironmentInfo } from '../pythonEnvironments/common/environmentManagers/conda';
98
import { EnvironmentType, PythonEnvironment } from '../pythonEnvironments/info';
109

11-
export const INTERPRETER_LOCATOR_SERVICE = 'IInterpreterLocatorService';
12-
export const WINDOWS_REGISTRY_SERVICE = 'WindowsRegistryService';
13-
export const CONDA_ENV_FILE_SERVICE = 'CondaEnvFileService';
14-
export const CONDA_ENV_SERVICE = 'CondaEnvService';
15-
export const CURRENT_PATH_SERVICE = 'CurrentPathService';
16-
export const KNOWN_PATH_SERVICE = 'KnownPathsService';
17-
export const GLOBAL_VIRTUAL_ENV_SERVICE = 'VirtualEnvService';
18-
export const WORKSPACE_VIRTUAL_ENV_SERVICE = 'WorkspaceVirtualEnvService';
19-
export const PIPENV_SERVICE = 'PipEnvService';
20-
export const IInterpreterVersionService = Symbol('IInterpreterVersionService');
21-
export interface IInterpreterVersionService {
22-
getVersion(pythonPath: string, defaultValue: string): Promise<string>;
23-
getPipVersion(pythonPath: string): Promise<string>;
24-
}
25-
26-
export const IKnownSearchPathsForInterpreters = Symbol('IKnownSearchPathsForInterpreters');
27-
export interface IKnownSearchPathsForInterpreters {
28-
getSearchPaths(): string[];
29-
}
30-
export const IVirtualEnvironmentsSearchPathProvider = Symbol('IVirtualEnvironmentsSearchPathProvider');
31-
export interface IVirtualEnvironmentsSearchPathProvider {
32-
getSearchPaths(resource?: Uri): Promise<string[]>;
33-
}
34-
3510
export type PythonEnvironmentsChangedEvent = {
3611
type?: FileChangeType;
3712
resource?: Uri;
@@ -74,15 +49,6 @@ export interface IComponentAdapter {
7449
isWindowsStoreInterpreter(pythonPath: string): Promise<boolean>;
7550
}
7651

77-
export const IInterpreterLocatorService = Symbol('IInterpreterLocatorService');
78-
79-
export interface IInterpreterLocatorService extends Disposable {
80-
readonly onLocating: Event<Promise<PythonEnvironment[]>>;
81-
readonly hasInterpreters: Promise<boolean>;
82-
didTriggerInterpreterSuggestions?: boolean;
83-
getInterpreters(resource?: Uri, options?: GetInterpreterOptions): Promise<PythonEnvironment[]>;
84-
}
85-
8652
export const ICondaService = Symbol('ICondaService');
8753
/**
8854
* Interface carries the properties which are not available via the discovery component interface.
@@ -94,20 +60,6 @@ export interface ICondaService {
9460
getCondaFileFromInterpreter(interpreterPath?: string, envName?: string): Promise<string | undefined>;
9561
}
9662

97-
export const ICondaLocatorService = Symbol('ICondaLocatorService');
98-
/**
99-
* @deprecated Use the new discovery component when in experiment, use this otherwise.
100-
*/
101-
export interface ICondaLocatorService {
102-
readonly condaEnvironmentsFile: string | undefined;
103-
getCondaFile(): Promise<string>;
104-
getCondaInfo(): Promise<CondaInfo | undefined>;
105-
getCondaEnvironments(ignoreCache: boolean): Promise<CondaEnvironmentInfo[] | undefined>;
106-
getInterpreterPath(condaEnvironmentPath: string): string;
107-
isCondaEnvironment(interpreterPath: string): Promise<boolean>;
108-
getCondaEnvironment(interpreterPath: string): Promise<CondaEnvironmentInfo | undefined>;
109-
}
110-
11163
export const IInterpreterService = Symbol('IInterpreterService');
11264
export interface IInterpreterService {
11365
readonly onRefreshStart: Event<void>;
@@ -119,7 +71,7 @@ export interface IInterpreterService {
11971
onDidChangeInterpreterInformation: Event<PythonEnvironment>;
12072
hasInterpreters(filter?: (e: PythonEnvironment) => Promise<boolean>): Promise<boolean>;
12173
getInterpreters(resource?: Uri): PythonEnvironment[];
122-
getAllInterpreters(resource?: Uri, options?: GetInterpreterOptions): Promise<PythonEnvironment[]>;
74+
getAllInterpreters(resource?: Uri): Promise<PythonEnvironment[]>;
12375
getActiveInterpreter(resource?: Uri): Promise<PythonEnvironment | undefined>;
12476
getInterpreterDetails(pythonPath: string, resoure?: Uri): Promise<undefined | PythonEnvironment>;
12577
refresh(resource: Resource): Promise<void>;
@@ -146,33 +98,6 @@ export interface IInterpreterHelper {
14698
getBestInterpreter(interpreters?: PythonEnvironment[]): PythonEnvironment | undefined;
14799
}
148100

149-
export const IPipEnvService = Symbol('IPipEnvService');
150-
export interface IPipEnvService extends IInterpreterLocatorService {
151-
executable: string;
152-
isRelatedPipEnvironment(dir: string, pythonPath: string): Promise<boolean>;
153-
}
154-
155-
export const IInterpreterLocatorHelper = Symbol('IInterpreterLocatorHelper');
156-
export interface IInterpreterLocatorHelper {
157-
mergeInterpreters(interpreters: PythonEnvironment[]): Promise<PythonEnvironment[]>;
158-
}
159-
160-
export const IInterpreterWatcher = Symbol('IInterpreterWatcher');
161-
export interface IInterpreterWatcher {
162-
onDidCreate: Event<Resource>;
163-
}
164-
165-
export const IInterpreterWatcherBuilder = Symbol('IInterpreterWatcherBuilder');
166-
export interface IInterpreterWatcherBuilder {
167-
getWorkspaceVirtualEnvInterpreterWatcher(resource: Resource): Promise<IInterpreterWatcher>;
168-
}
169-
170-
export const IInterpreterLocatorProgressService = Symbol('IInterpreterLocatorProgressService');
171-
export interface IInterpreterLocatorProgressService extends IExtensionSingleActivationService {
172-
readonly onRefreshing: Event<void>;
173-
readonly onRefreshed: Event<void>;
174-
}
175-
176101
export const IInterpreterStatusbarVisibilityFilter = Symbol('IInterpreterStatusbarVisibilityFilter');
177102
/**
178103
* Implement this interface to control the visibility of the interpreter statusbar.
@@ -186,5 +111,3 @@ export type WorkspacePythonPath = {
186111
folderUri: Uri;
187112
configTarget: ConfigurationTarget.Workspace | ConfigurationTarget.WorkspaceFolder;
188113
};
189-
190-
export type GetInterpreterOptions = { ignoreCache?: boolean; onSuggestion?: boolean };

extensions/positron-python/src/client/interpreter/interpreterVersion.ts

Lines changed: 0 additions & 37 deletions
This file was deleted.

extensions/positron-python/src/client/interpreter/serviceRegistry.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,12 @@ import {
2323
IPythonPathUpdaterServiceFactory,
2424
IPythonPathUpdaterServiceManager,
2525
} from './configuration/types';
26-
import {
27-
IInterpreterDisplay,
28-
IInterpreterHelper,
29-
IInterpreterService,
30-
IInterpreterVersionService,
31-
IShebangCodeLensProvider,
32-
} from './contracts';
26+
import { IInterpreterDisplay, IInterpreterHelper, IInterpreterService, IShebangCodeLensProvider } from './contracts';
3327
import { InterpreterDisplay } from './display';
3428
import { InterpreterLocatorProgressStatubarHandler } from './display/progressDisplay';
3529
import { ShebangCodeLensProvider } from './display/shebangCodeLensProvider';
3630
import { InterpreterHelper } from './helpers';
3731
import { InterpreterService } from './interpreterService';
38-
import { InterpreterVersionService } from './interpreterVersion';
3932
import { CondaInheritEnvPrompt } from './virtualEnvs/condaInheritEnvPrompt';
4033
import { VirtualEnvironmentPrompt } from './virtualEnvs/virtualEnvPrompt';
4134

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

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

65-
serviceManager.addSingleton<IInterpreterVersionService>(IInterpreterVersionService, InterpreterVersionService);
66-
6758
serviceManager.addSingleton<IInterpreterService>(IInterpreterService, InterpreterService);
6859
serviceManager.addSingleton<IInterpreterDisplay>(IInterpreterDisplay, InterpreterDisplay);
6960

0 commit comments

Comments
 (0)