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

Request for unstable API permission for an extension #16221

Closed
gjsjohnmurray opened this issue Nov 11, 2024 · 7 comments
Closed

Request for unstable API permission for an extension #16221

gjsjohnmurray opened this issue Nov 11, 2024 · 7 comments
Assignees
Labels
feature-request Request for new features or functionality

Comments

@gjsjohnmurray
Copy link
Contributor

Please allow the extension Jupyter Server Proxy for InterSystems IRIS (intersystems-community.iris-jupyter-server) to use unstable API in production.

@gjsjohnmurray gjsjohnmurray added the feature-request Request for new features or functionality label Nov 11, 2024
@DonJayamanne
Copy link
Contributor

@gjsjohnmurray

Thanks for looking into this.
Please can you confirm the id of the extension is as follows intersystems-community.iris-jupyter-server
I'll add this once confirmed,

Also added a general note on using proposed API https://github.com/microsoft/vscode-jupyter/wiki/Extension-API
I'm sure you're no stranger to this.
TLDR, with the API you are planning on using, we have no plans to change this, its used in at least 2 other extensions (Jupyter Hub and another inhouse extension)
I.e. it is very safe to use this, though its not yet stable.

@gjsjohnmurray
Copy link
Contributor Author

Yes, that is the correct id.

@DonJayamanne
Copy link
Contributor

@gjsjohnmurray I think you should be able to use this today, npm i @vscode/jupyter-extension@proposed
Please use just the following proposed API, I believe thats all you will need

    export interface JupyterServerConnectionInformation {
        /**
         * The `fetch` method to use.
         */
        readonly fetch?: (input: RequestInfo, init?: RequestInit) => Promise<Response>;
        /**
         * The `WebSocket` object constructor.
         */
        readonly WebSocket?: typeof WebSocket;

Let me know if it doesn't work for you.
All you need is provide your own fetch implementation and the Jupyter extension will call into that for sure. similarly for websockets.

@gjsjohnmurray
Copy link
Contributor Author

@DonJayamanne I am trying to use getKernelService

const jupyterKernelService = await jupyterApi.getKernelService();
if (!jupyterKernelService) {
	vscode.window.showErrorMessage('Cannot access jupyterApi.getKernelService() - try using VS Code Insiders');
	return;
}

Next I create a new notebook:

await vscode.commands.executeCommand('ipynb.newUntitledIpynb');
const nbEditor = vscode.window.activeNotebookEditor;

Get the kernel specifications:

const kernelConnectionMetadataArray = await jupyterKernelService.getKernelSpecifications();

I then search the array to get an id I can use as an argument to your API's openNotebook:

const kernelConnectionMetadata = kernelConnectionMetadataArray.find((item: any) => item.kind === 'startUsingRemoteKernelSpec' && item.baseUrl === myBaseUrl && item.kernelSpec.name === myKernelSpecName);
await jupyterApi.openNotebook(nbUri, kernelConnectionMetadata.id);

It's working well on VS Code Insiders, but on Stable I'm getting this notification:

Image

AFAIK you'd need to add my extension id to a list somewhere to make this possible on Stable.

@DonJayamanne
Copy link
Contributor

‘ getKernelService’ should not be used
Please have a look at the Jupyterhub extension
https://github.com/microsoft/vscode-jupyter-hub/blob/5d684bbee59ab8911e99e89a08a7adb4600df3b8/src/jupyterIntegration.ts#L308

@gjsjohnmurray
Copy link
Contributor Author

At this point I'm not trying to replace my fake jupyter server with your proxy fetch and websocket mechanism (see your comment intersystems-community/vscode-iris-jupyter-server#6 (comment)). Rather, having successfully migrated to the finalized JupyterServerProvider API I've been trying to add a way from our UI's tree of servers to be able to launch a new notebook using one of the kernelspecs that the target server provides.

To visualize my goal, imagine adding "Create Interactive Window" and "Create Jupyter Notebook" buttons on the Kernel Specifications rows of your Jupyter Powertoys extension:

Image

I know the baseUrl and the kernelSpec.name but what I need to pass to your openNotebook function is the id of the matching kernelConnectionMetadata item.

Maybe a better solution than me using getKernelService is for you to make openNotebook accept this alternative object in its second argument:

{ kind: 'startUsingRemoteKernelSpec', baseUrl: 'http://localhost:50773/irislatest:USER', kernelSpecName: 'objectscript-int' }

leaving it down to you to match those values in your kernelConnectionMetadata[] array and get the id that I currently have to pass in on the openNotebook call.

@DonJayamanne
Copy link
Contributor

Thank you for getting back
Unfortunately at this stage we’re trying to deprecate that other api completely and remove it
Just have to extensions that use that today (power toy and another)

Please can you file a new issue with your requirements so we can track and discuss that separately
Let’s start with the assumption that the old api has been removed/don’t exist

Thanks again
Going to close this issue so we can start a separate discussion on a new issue

gjsjohnmurray added a commit to intersystems-community/vscode-iris-jupyter-server that referenced this issue Nov 15, 2024
It used unstable API from the Jupyter extension which isn't likely to stabilize (see microsoft/vscode-jupyter#16221)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests

2 participants