Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unwanted Jupyter API #21702

Merged
merged 3 commits into from
Jul 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 1 addition & 59 deletions pythonExtensionApi/src/main.ts
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -12,9 +12,6 @@ export interface PythonExtension {
* Promise indicating whether all parts of the extension have completed loading or not.
*/
ready: Promise<void>;
jupyter: {
registerHooks(): void;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No point exposing this in the public API, as this will never be used anyone else, except jupyter
Also technically this is a private handshake between the two extensions, hence removing from public API

};
debug: {
/**
* Generate an array of strings for commands to pass to the Python executable to launch the debugger for remote debugging.
Expand All @@ -33,20 +30,6 @@ export interface PythonExtension {
getDebuggerPackagePath(): Promise<string | undefined>;
};

datascience: {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These were moved into the Jupyter extension a couple of few years ago (probably 2).

/**
* 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<void>;
/**
* 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
Expand Down Expand Up @@ -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<JupyterServerUriHandle | 'back' | undefined>;
getServerUri(handle: JupyterServerUriHandle): Promise<IJupyterServerUri>;
}

interface IDataFrameInfo {
columns?: { key: string; type: ColumnType }[];
indexColumn?: string;
rowCount?: number;
}

export interface IDataViewerDataProvider {
dispose(): void;
getDataFrameInfo(): Promise<IDataFrameInfo>;
getAllRows(): Promise<IRowsResponse>;
getRows(start: number, end: number): Promise<IRowsResponse>;
}

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
Expand Down
12 changes: 0 additions & 12 deletions src/client/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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';
Expand Down Expand Up @@ -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<void>),
},
pylance: {
createClient: (...args: any[]): BaseLanguageClient => {
// Make sure we share output channel so that we can share one with
Expand Down
14 changes: 0 additions & 14 deletions src/client/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,6 @@ export interface PythonExtension {
getDebuggerPackagePath(): Promise<string | undefined>;
};

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<void>;
/**
* 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
Expand Down
30 changes: 0 additions & 30 deletions src/client/jupyter/jupyterIntegration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
/**
Expand Down Expand Up @@ -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<void>;
/**
* 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()
Expand Down Expand Up @@ -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<void> {
const api = await this.getExtensionApi();
if (api) {
return api.showDataViewer(dataProvider, title);
}
return undefined;
}

private async getExtensionApi(): Promise<JupyterExtensionApi | undefined> {
if (!this.pylanceExtension) {
const pylanceExtension = this.extensions.getExtension<PylanceApi>(PYLANCE_EXTENSION_ID);
Expand Down
Loading