Skip to content

Commit 358635d

Browse files
authored
Remove old and unused API for Jupyter Ext (#21731)
We have not used any of this API for a while now, hence its safe to remove these. Will be removing more soon.
1 parent 8f3d60b commit 358635d

File tree

8 files changed

+6
-342
lines changed

8 files changed

+6
-342
lines changed

src/client/common/installer/condaInstaller.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -88,18 +88,7 @@ export class CondaInstaller extends ModuleInstaller {
8888
// Found that using conda-forge is best at packages like tensorboard & ipykernel which seem to get updated first on conda-forge
8989
// https://github.com/microsoft/vscode-jupyter/issues/7787 & https://github.com/microsoft/vscode-python/issues/17628
9090
// Do this just for the datascience packages.
91-
if (
92-
[
93-
Product.tensorboard,
94-
Product.ipykernel,
95-
Product.pandas,
96-
Product.nbconvert,
97-
Product.jupyter,
98-
Product.notebook,
99-
]
100-
.map(translateProductToModule)
101-
.includes(moduleName)
102-
) {
91+
if ([Product.tensorboard].map(translateProductToModule).includes(moduleName)) {
10392
args.push('-c', 'conda-forge');
10493
}
10594
if (info && info.name) {

src/client/common/installer/moduleInstaller.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -264,18 +264,6 @@ export function translateProductToModule(product: Product): string {
264264
return 'unittest';
265265
case Product.bandit:
266266
return 'bandit';
267-
case Product.jupyter:
268-
return 'jupyter';
269-
case Product.notebook:
270-
return 'notebook';
271-
case Product.pandas:
272-
return 'pandas';
273-
case Product.ipykernel:
274-
return 'ipykernel';
275-
case Product.nbconvert:
276-
return 'nbconvert';
277-
case Product.kernelspec:
278-
return 'kernelspec';
279267
case Product.tensorboard:
280268
return 'tensorboard';
281269
case Product.torchProfilerInstallName:

src/client/common/installer/productNames.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,5 @@ ProductNames.set(Product.yapf, 'yapf');
1919
ProductNames.set(Product.tensorboard, 'tensorboard');
2020
ProductNames.set(Product.torchProfilerInstallName, 'torch-tb-profiler');
2121
ProductNames.set(Product.torchProfilerImportName, 'torch_tb_profiler');
22-
ProductNames.set(Product.jupyter, 'jupyter');
23-
ProductNames.set(Product.notebook, 'notebook');
24-
ProductNames.set(Product.ipykernel, 'ipykernel');
25-
ProductNames.set(Product.nbconvert, 'nbconvert');
26-
ProductNames.set(Product.kernelspec, 'kernelspec');
27-
ProductNames.set(Product.pandas, 'pandas');
2822
ProductNames.set(Product.pip, 'pip');
2923
ProductNames.set(Product.ensurepip, 'ensurepip');

src/client/common/installer/productService.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,6 @@ export class ProductService implements IProductService {
2525
this.ProductTypes.set(Product.autopep8, ProductType.Formatter);
2626
this.ProductTypes.set(Product.black, ProductType.Formatter);
2727
this.ProductTypes.set(Product.yapf, ProductType.Formatter);
28-
this.ProductTypes.set(Product.jupyter, ProductType.DataScience);
29-
this.ProductTypes.set(Product.notebook, ProductType.DataScience);
30-
this.ProductTypes.set(Product.ipykernel, ProductType.DataScience);
31-
this.ProductTypes.set(Product.nbconvert, ProductType.DataScience);
32-
this.ProductTypes.set(Product.kernelspec, ProductType.DataScience);
33-
this.ProductTypes.set(Product.pandas, ProductType.DataScience);
3428
this.ProductTypes.set(Product.tensorboard, ProductType.DataScience);
3529
this.ProductTypes.set(Product.torchProfilerInstallName, ProductType.DataScience);
3630
this.ProductTypes.set(Product.torchProfilerImportName, ProductType.DataScience);

src/client/common/types.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,6 @@ export enum Product {
109109
isort = 15,
110110
black = 16,
111111
bandit = 17,
112-
jupyter = 18,
113-
ipykernel = 19,
114-
notebook = 20,
115-
kernelspec = 21,
116-
nbconvert = 22,
117-
pandas = 23,
118112
tensorboard = 24,
119113
torchProfilerInstallName = 25,
120114
torchProfilerImportName = 26,

src/client/jupyter/jupyterIntegration.ts

Lines changed: 3 additions & 141 deletions
Original file line numberDiff line numberDiff line change
@@ -6,90 +6,20 @@
66

77
import { inject, injectable, named } from 'inversify';
88
import { dirname } from 'path';
9-
import { CancellationToken, Event, Extension, Memento, Uri } from 'vscode';
9+
import { Extension, Memento, Uri } from 'vscode';
1010
import type { SemVer } from 'semver';
1111
import { IContextKeyManager, IWorkspaceService } from '../common/application/types';
1212
import { JUPYTER_EXTENSION_ID, PYLANCE_EXTENSION_ID } from '../common/constants';
13-
import { InterpreterUri, ModuleInstallFlags } from '../common/installer/types';
14-
import {
15-
GLOBAL_MEMENTO,
16-
IExtensions,
17-
IInstaller,
18-
IMemento,
19-
InstallerResponse,
20-
Product,
21-
ProductInstallStatus,
22-
Resource,
23-
} from '../common/types';
13+
import { GLOBAL_MEMENTO, IExtensions, IMemento, Resource } from '../common/types';
2414
import { getDebugpyPackagePath } from '../debugger/extension/adapter/remoteLaunchers';
2515
import { IEnvironmentActivationService } from '../interpreter/activation/types';
2616
import { IInterpreterQuickPickItem, IInterpreterSelector } from '../interpreter/configuration/types';
27-
import {
28-
IComponentAdapter,
29-
ICondaService,
30-
IInterpreterDisplay,
31-
IInterpreterService,
32-
IInterpreterStatusbarVisibilityFilter,
33-
PythonEnvironmentsChangedEvent,
34-
} from '../interpreter/contracts';
17+
import { ICondaService, IInterpreterDisplay, IInterpreterStatusbarVisibilityFilter } from '../interpreter/contracts';
3518
import { PythonEnvironment } from '../pythonEnvironments/info';
3619
import { PylanceApi } from '../activation/node/pylanceApi';
3720
import { ExtensionContextKey } from '../common/application/contextKeys';
38-
/**
39-
* This allows Python extension to update Product enum without breaking Jupyter.
40-
* I.e. we have a strict contract, else using numbers (in enums) is bound to break across products.
41-
*/
42-
enum JupyterProductToInstall {
43-
jupyter = 'jupyter',
44-
ipykernel = 'ipykernel',
45-
notebook = 'notebook',
46-
kernelspec = 'kernelspec',
47-
nbconvert = 'nbconvert',
48-
pandas = 'pandas',
49-
pip = 'pip',
50-
}
51-
52-
const ProductMapping: { [key in JupyterProductToInstall]: Product } = {
53-
[JupyterProductToInstall.ipykernel]: Product.ipykernel,
54-
[JupyterProductToInstall.jupyter]: Product.jupyter,
55-
[JupyterProductToInstall.kernelspec]: Product.kernelspec,
56-
[JupyterProductToInstall.nbconvert]: Product.nbconvert,
57-
[JupyterProductToInstall.notebook]: Product.notebook,
58-
[JupyterProductToInstall.pandas]: Product.pandas,
59-
[JupyterProductToInstall.pip]: Product.pip,
60-
};
6121

6222
type PythonApiForJupyterExtension = {
63-
/**
64-
* IInterpreterService
65-
*/
66-
onDidChangeInterpreter: Event<Uri | undefined>;
67-
/**
68-
* IInterpreterService
69-
*/
70-
readonly refreshPromise: Promise<void> | undefined;
71-
/**
72-
* IInterpreterService
73-
*/
74-
readonly onDidChangeInterpreters: Event<PythonEnvironmentsChangedEvent>;
75-
/**
76-
* Equivalent to getInterpreters() in IInterpreterService
77-
*/
78-
getKnownInterpreters(resource?: Uri): PythonEnvironment[];
79-
/**
80-
* @deprecated Use `getKnownInterpreters`, `onDidChangeInterpreters`, and `refreshPromise` instead.
81-
* Equivalent to getAllInterpreters() in IInterpreterService
82-
*/
83-
getInterpreters(resource?: Uri): Promise<PythonEnvironment[]>;
84-
/**
85-
* IInterpreterService
86-
*/
87-
getActiveInterpreter(resource?: Uri): Promise<PythonEnvironment | undefined>;
88-
/**
89-
* IInterpreterService
90-
*/
91-
getInterpreterDetails(pythonPath: string, resource?: Uri): Promise<undefined | PythonEnvironment>;
92-
9323
/**
9424
* IEnvironmentActivationService
9525
*/
@@ -98,31 +28,11 @@ type PythonApiForJupyterExtension = {
9828
interpreter?: PythonEnvironment,
9929
allowExceptions?: boolean,
10030
): Promise<NodeJS.ProcessEnv | undefined>;
101-
isMicrosoftStoreInterpreter(pythonPath: string): Promise<boolean>;
102-
suggestionToQuickPickItem(suggestion: PythonEnvironment, workspaceUri?: Uri | undefined): IInterpreterQuickPickItem;
10331
getKnownSuggestions(resource: Resource): IInterpreterQuickPickItem[];
10432
/**
10533
* @deprecated Use `getKnownSuggestions` and `suggestionToQuickPickItem` instead.
10634
*/
10735
getSuggestions(resource: Resource): Promise<IInterpreterQuickPickItem[]>;
108-
/**
109-
* IInstaller
110-
*/
111-
install(
112-
product: JupyterProductToInstall,
113-
resource?: InterpreterUri,
114-
cancel?: CancellationToken,
115-
reInstallAndUpdate?: boolean,
116-
installPipIfRequired?: boolean,
117-
): Promise<InstallerResponse>;
118-
/**
119-
* IInstaller
120-
*/
121-
isProductVersionCompatible(
122-
product: Product,
123-
semVerRequirement: string,
124-
resource?: InterpreterUri,
125-
): Promise<ProductInstallStatus>;
12636
/**
12737
* Returns path to where `debugpy` is. In python extension this is `/pythonFiles/lib/python`.
12838
*/
@@ -140,10 +50,6 @@ type PythonApiForJupyterExtension = {
14050
* Returns the conda executable.
14151
*/
14252
getCondaFile(): Promise<string | undefined>;
143-
getEnvironmentActivationShellCommands(
144-
resource: Resource,
145-
interpreter?: PythonEnvironment,
146-
): Promise<string[] | undefined>;
14753

14854
/**
14955
* Call to provide a function that the Python extension can call to request the Python
@@ -181,13 +87,10 @@ export class JupyterExtensionIntegration {
18187

18288
constructor(
18389
@inject(IExtensions) private readonly extensions: IExtensions,
184-
@inject(IInterpreterService) private readonly interpreterService: IInterpreterService,
18590
@inject(IInterpreterSelector) private readonly interpreterSelector: IInterpreterSelector,
186-
@inject(IInstaller) private readonly installer: IInstaller,
18791
@inject(IEnvironmentActivationService) private readonly envActivation: IEnvironmentActivationService,
18892
@inject(IMemento) @named(GLOBAL_MEMENTO) private globalState: Memento,
18993
@inject(IInterpreterDisplay) private interpreterDisplay: IInterpreterDisplay,
190-
@inject(IComponentAdapter) private pyenvs: IComponentAdapter,
19194
@inject(IWorkspaceService) private workspaceService: IWorkspaceService,
19295
@inject(ICondaService) private readonly condaService: ICondaService,
19396
@inject(IContextKeyManager) private readonly contextManager: IContextKeyManager,
@@ -201,54 +104,15 @@ export class JupyterExtensionIntegration {
201104
}
202105
// Forward python parts
203106
jupyterExtensionApi.registerPythonApi({
204-
onDidChangeInterpreter: this.interpreterService.onDidChangeInterpreter,
205-
getActiveInterpreter: async (resource?: Uri) => this.interpreterService.getActiveInterpreter(resource),
206-
getInterpreterDetails: async (pythonPath: string) =>
207-
this.interpreterService.getInterpreterDetails(pythonPath),
208-
refreshPromise: this.interpreterService.refreshPromise,
209-
onDidChangeInterpreters: this.interpreterService.onDidChangeInterpreters,
210-
getKnownInterpreters: (resource: Uri | undefined) => this.pyenvs.getInterpreters(resource),
211-
getInterpreters: async (resource: Uri | undefined) => this.interpreterService.getAllInterpreters(resource),
212107
getActivatedEnvironmentVariables: async (
213108
resource: Resource,
214109
interpreter?: PythonEnvironment,
215110
allowExceptions?: boolean,
216111
) => this.envActivation.getActivatedEnvironmentVariables(resource, interpreter, allowExceptions),
217-
isMicrosoftStoreInterpreter: async (pythonPath: string): Promise<boolean> =>
218-
this.pyenvs.isMicrosoftStoreInterpreter(pythonPath),
219112
getSuggestions: async (resource: Resource): Promise<IInterpreterQuickPickItem[]> =>
220113
this.interpreterSelector.getAllSuggestions(resource),
221114
getKnownSuggestions: (resource: Resource): IInterpreterQuickPickItem[] =>
222115
this.interpreterSelector.getSuggestions(resource),
223-
suggestionToQuickPickItem: (
224-
suggestion: PythonEnvironment,
225-
workspaceUri?: Uri | undefined,
226-
): IInterpreterQuickPickItem =>
227-
this.interpreterSelector.suggestionToQuickPickItem(suggestion, workspaceUri),
228-
install: async (
229-
product: JupyterProductToInstall,
230-
resource?: InterpreterUri,
231-
cancel?: CancellationToken,
232-
reInstallAndUpdate?: boolean,
233-
installPipIfRequired?: boolean,
234-
): Promise<InstallerResponse> => {
235-
let flags =
236-
reInstallAndUpdate === true
237-
? ModuleInstallFlags.updateDependencies | ModuleInstallFlags.reInstall
238-
: undefined;
239-
if (installPipIfRequired === true) {
240-
flags = flags
241-
? flags | ModuleInstallFlags.installPipIfRequired
242-
: ModuleInstallFlags.installPipIfRequired;
243-
}
244-
return this.installer.install(ProductMapping[product], resource, cancel, flags);
245-
},
246-
isProductVersionCompatible: async (
247-
product: Product,
248-
semVerRequirement: string,
249-
resource?: InterpreterUri,
250-
): Promise<ProductInstallStatus> =>
251-
this.installer.isProductVersionCompatible(product, semVerRequirement, resource),
252116
getDebuggerPath: async () => dirname(getDebugpyPackagePath()),
253117
getInterpreterPathSelectedForJupyterServer: () =>
254118
this.globalState.get<string | undefined>('INTERPRETER_PATH_SELECTED_FOR_JUPYTER_SERVER'),
@@ -257,8 +121,6 @@ export class JupyterExtensionIntegration {
257121
),
258122
getCondaFile: () => this.condaService.getCondaFile(),
259123
getCondaVersion: () => this.condaService.getCondaVersion(),
260-
getEnvironmentActivationShellCommands: (resource: Resource, interpreter?: PythonEnvironment) =>
261-
this.envActivation.getEnvironmentActivationShellCommands(resource, interpreter),
262124
registerJupyterPythonPathFunction: (func: (uri: Uri) => Promise<string | undefined>) =>
263125
this.registerJupyterPythonPathFunction(func),
264126
registerGetNotebookUriForTextDocumentUriFunction: (func: (textDocumentUri: Uri) => Uri | undefined) =>

src/test/activation/node/lspInteractiveWindowMiddlewareAddon.unit.test.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,8 @@ import { anything, capture, instance, mock, verify, when } from 'ts-mockito';
1010
import { LanguageClient } from 'vscode-languageclient/node';
1111
import { LspInteractiveWindowMiddlewareAddon } from '../../../client/activation/node/lspInteractiveWindowMiddlewareAddon';
1212
import { JupyterExtensionIntegration } from '../../../client/jupyter/jupyterIntegration';
13-
import { IExtensions, IInstaller } from '../../../client/common/types';
14-
import {
15-
IComponentAdapter,
16-
ICondaService,
17-
IInterpreterDisplay,
18-
IInterpreterService,
19-
} from '../../../client/interpreter/contracts';
13+
import { IExtensions } from '../../../client/common/types';
14+
import { ICondaService, IInterpreterDisplay } from '../../../client/interpreter/contracts';
2015
import { IInterpreterSelector } from '../../../client/interpreter/configuration/types';
2116
import { IEnvironmentActivationService } from '../../../client/interpreter/activation/types';
2217
import { IContextKeyManager, IWorkspaceService } from '../../../client/common/application/types';
@@ -32,13 +27,10 @@ suite('Pylance Language Server - Interactive Window LSP Notebooks', () => {
3227
languageClient = instance(languageClientMock);
3328
jupyterApi = new JupyterExtensionIntegration(
3429
mock<IExtensions>(),
35-
mock<IInterpreterService>(),
3630
mock<IInterpreterSelector>(),
37-
mock<IInstaller>(),
3831
mock<IEnvironmentActivationService>(),
3932
new MockMemento(),
4033
mock<IInterpreterDisplay>(),
41-
mock<IComponentAdapter>(),
4234
mock<IWorkspaceService>(),
4335
mock<ICondaService>(),
4436
mock<IContextKeyManager>(),

0 commit comments

Comments
 (0)