From 11a9f1d2a9a81097d16ce5f71385faa730bb7236 Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Mon, 31 Jul 2023 23:34:41 +1000 Subject: [PATCH] Remove unwanted Jupyter API (#21702) Fixes https://github.com/microsoft/vscode-jupyter/issues/13986 --- pythonExtensionApi/src/main.ts | 60 +----------------------- src/client/api.ts | 12 ----- src/client/api/types.ts | 14 ------ src/client/jupyter/jupyterIntegration.ts | 30 ------------ 4 files changed, 1 insertion(+), 115 deletions(-) diff --git a/pythonExtensionApi/src/main.ts b/pythonExtensionApi/src/main.ts index cf1461f04d81..4de554bf5a24 100644 --- a/pythonExtensionApi/src/main.ts +++ b/pythonExtensionApi/src/main.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { CancellationToken, Event, Uri, WorkspaceFolder, QuickPickItem, extensions } from 'vscode'; +import { CancellationToken, Event, Uri, WorkspaceFolder, extensions } from 'vscode'; /* * Do not introduce any breaking changes to this API. @@ -12,9 +12,6 @@ export interface PythonExtension { * Promise indicating whether all parts of the extension have completed loading or not. */ ready: Promise; - jupyter: { - registerHooks(): void; - }; debug: { /** * Generate an array of strings for commands to pass to the Python executable to launch the debugger for remote debugging. @@ -33,20 +30,6 @@ export interface PythonExtension { getDebuggerPackagePath(): Promise; }; - datascience: { - /** - * Launches Data Viewer component. - * @param dataProvider Instance that will be used by the Data Viewer component to fetch data. - * @param title Data Viewer title - */ - showDataViewer(dataProvider: IDataViewerDataProvider, title: string): Promise; - /** - * Registers a remote server provider component that's used to pick remote jupyter server URIs - * @param serverProvider object called back when picking jupyter server URI - */ - registerRemoteServerProvider(serverProvider: IJupyterUriProvider): void; - }; - /** * These APIs provide a way for extensions to work with by python environments available in the user's machine * as found by the Python extension. See @@ -123,47 +106,6 @@ export interface PythonExtension { }; } -interface IJupyterServerUri { - baseUrl: string; - token: string; - - // eslint-disable-next-line @typescript-eslint/no-explicit-any - authorizationHeader: any; // JSON object for authorization header. - expiration?: Date; // Date/time when header expires and should be refreshed. - displayName: string; -} - -type JupyterServerUriHandle = string; - -export interface IJupyterUriProvider { - readonly id: string; // Should be a unique string (like a guid) - getQuickPickEntryItems(): QuickPickItem[]; - handleQuickPick(item: QuickPickItem, backEnabled: boolean): Promise; - getServerUri(handle: JupyterServerUriHandle): Promise; -} - -interface IDataFrameInfo { - columns?: { key: string; type: ColumnType }[]; - indexColumn?: string; - rowCount?: number; -} - -export interface IDataViewerDataProvider { - dispose(): void; - getDataFrameInfo(): Promise; - getAllRows(): Promise; - getRows(start: number, end: number): Promise; -} - -enum ColumnType { - String = 'string', - Number = 'number', - Bool = 'bool', -} - -// eslint-disable-next-line @typescript-eslint/no-explicit-any -type IRowsResponse = any[]; - export type RefreshOptions = { /** * When `true`, force trigger a refresh regardless of whether a refresh was already triggered. Note this can be expensive so diff --git a/src/client/api.ts b/src/client/api.ts index 32ce68f6a28b..2371a4d88de1 100644 --- a/src/client/api.ts +++ b/src/client/api.ts @@ -4,7 +4,6 @@ 'use strict'; -import { noop } from 'lodash'; import { Uri, Event } from 'vscode'; import { BaseLanguageClient, LanguageClientOptions } from 'vscode-languageclient'; import { LanguageClient } from 'vscode-languageclient/node'; @@ -17,7 +16,6 @@ import { getDebugpyLauncherArgs, getDebugpyPackagePath } from './debugger/extens import { IInterpreterService } from './interpreter/contracts'; import { IServiceContainer, IServiceManager } from './ioc/types'; import { JupyterExtensionIntegration } from './jupyter/jupyterIntegration'; -import { IDataViewerDataProvider, IJupyterUriProvider } from './jupyter/types'; import { traceError } from './logging'; import { IDiscoveryAPI } from './pythonEnvironments/base/locator'; import { buildEnvironmentApi } from './environmentApi'; @@ -111,16 +109,6 @@ export function buildApi( return { execCommand: pythonPath === '' ? undefined : [pythonPath] }; }, }, - // These are for backwards compatibility. Other extensions are using these APIs and we don't want - // to force them to move to the jupyter extension ... yet. - datascience: { - registerRemoteServerProvider: jupyterIntegration - ? jupyterIntegration.registerRemoteServerProvider.bind(jupyterIntegration) - : ((noop as unknown) as (serverProvider: IJupyterUriProvider) => void), - showDataViewer: jupyterIntegration - ? jupyterIntegration.showDataViewer.bind(jupyterIntegration) - : ((noop as unknown) as (dataProvider: IDataViewerDataProvider, title: string) => Promise), - }, pylance: { createClient: (...args: any[]): BaseLanguageClient => { // Make sure we share output channel so that we can share one with diff --git a/src/client/api/types.ts b/src/client/api/types.ts index cf1461f04d81..63954a16d868 100644 --- a/src/client/api/types.ts +++ b/src/client/api/types.ts @@ -33,20 +33,6 @@ export interface PythonExtension { getDebuggerPackagePath(): Promise; }; - datascience: { - /** - * Launches Data Viewer component. - * @param dataProvider Instance that will be used by the Data Viewer component to fetch data. - * @param title Data Viewer title - */ - showDataViewer(dataProvider: IDataViewerDataProvider, title: string): Promise; - /** - * Registers a remote server provider component that's used to pick remote jupyter server URIs - * @param serverProvider object called back when picking jupyter server URI - */ - registerRemoteServerProvider(serverProvider: IJupyterUriProvider): void; - }; - /** * These APIs provide a way for extensions to work with by python environments available in the user's machine * as found by the Python extension. See diff --git a/src/client/jupyter/jupyterIntegration.ts b/src/client/jupyter/jupyterIntegration.ts index a0fa0fedb63f..7f660d26e5e4 100644 --- a/src/client/jupyter/jupyterIntegration.ts +++ b/src/client/jupyter/jupyterIntegration.ts @@ -33,7 +33,6 @@ import { PythonEnvironmentsChangedEvent, } from '../interpreter/contracts'; import { PythonEnvironment } from '../pythonEnvironments/info'; -import { IDataViewerDataProvider, IJupyterUriProvider } from './types'; import { PylanceApi } from '../activation/node/pylanceApi'; import { ExtensionContextKey } from '../common/application/contextKeys'; /** @@ -168,17 +167,6 @@ type JupyterExtensionApi = { * @param interpreterService */ registerPythonApi(interpreterService: PythonApiForJupyterExtension): void; - /** - * Launches Data Viewer component. - * @param {IDataViewerDataProvider} dataProvider Instance that will be used by the Data Viewer component to fetch data. - * @param {string} title Data Viewer title - */ - showDataViewer(dataProvider: IDataViewerDataProvider, title: string): Promise; - /** - * Registers a remote server provider component that's used to pick remote jupyter server URIs - * @param serverProvider object called back when picking jupyter server URI - */ - registerRemoteServerProvider(serverProvider: IJupyterUriProvider): void; }; @injectable() @@ -286,24 +274,6 @@ export class JupyterExtensionIntegration { } } - public registerRemoteServerProvider(serverProvider: IJupyterUriProvider): void { - this.getExtensionApi() - .then((e) => { - if (e) { - e.registerRemoteServerProvider(serverProvider); - } - }) - .ignoreErrors(); - } - - public async showDataViewer(dataProvider: IDataViewerDataProvider, title: string): Promise { - const api = await this.getExtensionApi(); - if (api) { - return api.showDataViewer(dataProvider, title); - } - return undefined; - } - private async getExtensionApi(): Promise { if (!this.pylanceExtension) { const pylanceExtension = this.extensions.getExtension(PYLANCE_EXTENSION_ID);