vscode-jupyter icon indicating copy to clipboard operation
vscode-jupyter copied to clipboard

Remove Python ext API `registerGetNotebookUriForTextDocumentUriFunction` and move code into Python/Pylance extension

Open DonJayamanne opened this issue 1 year ago • 8 comments

Given that

  • Interactive window is a core feature in VS Code,
  • and all of the code used to get the Notebook Uri for the above function is not relying on any Jupyter ext,

its simpler (for maintenance) to move this code into Python/Pylance extension.

This is one less API in Python extension.

Thoughts/Concerns ? @karthiknadig @amunger @debonte

DonJayamanne avatar Jan 04 '24 08:01 DonJayamanne

I imagine this would helped by https://github.com/microsoft/vscode/issues/154983 or even made unnecessary.

amunger avatar Jan 04 '24 16:01 amunger

I do not believe that would help, Neither Pylance nor Python extension will not be able to use that API to determine whether a given URI is an interacrtive URI belonging to a particular notebook or not.

DonJayamanne avatar Jan 04 '24 19:01 DonJayamanne

I started trying to move this code into Pylance and found that it calls isInteractiveInputTab which uses vscode-jupyter's InteractiveTab and TabInputInteractiveWindow types. Are the structures of these types well-defined? It looks like maybe they are vscode types that vscode-jupyter duplicated?

debonte avatar Jan 18 '24 02:01 debonte

Are the structures of these types well-defined? It looks like maybe they are vscode types that vscode-jupyter duplicated?

Hmm, yes you are right, perhaps @amunger might have some idea why we copied the types. I believe you could either copy the types (as done here) or just add the proposed API into pylance to just get the type definitions (and ensure there's a very strict contract, to catch changes to the types).

DonJayamanne avatar Jan 18 '24 03:01 DonJayamanne

I've removed the API from Pylance, so Pylance will no longer be relying on Python/Jupyter to provide a function to resolve the input box URI to a notebook URI. We're aiming to ship a prerelease build today (2023.12.104) that will include this change and we should be shipping a stable/release build in the next week or so.

I think once Pylance's stable build includes my change it should be safe for Python and Jupyter to remove their related code. Anyone that hits compatibility issues (ex. new Python + old Pylance) can be told to upgrade Pylance. @DonJayamanne, @karthiknadig, do you agree?

cc: @luabud

debonte avatar Jan 22 '24 17:01 debonte

@debonte Yes, it makes sense me. for compatibility we could also set the engine number so that the right versions match for pylance/python/jupyter.

karthiknadig avatar Jan 25 '24 23:01 karthiknadig

@debonte thanks, I will prepare a PR to remote this API from Jupyter extension (but will wait for Pylance to first ship befmore merging this PR)

Any idea when the next stable version goes out? is it lined up with the Python/vscode release schedule?

DonJayamanne avatar Jan 28 '24 12:01 DonJayamanne

Any idea when the next stable version goes out? is it lined up with the Python/vscode release schedule?

Likely sometime this week. We are not in strict alignment with the vscode release schedule.

debonte avatar Jan 30 '24 00:01 debonte

I will be removing the registerGetNotebookUriForTextDocumentUri function from Jupyter extension The corresponding code from Python extension will need to go, however that impacts the following tests as well src/test/activation/node/lspInteractiveWindowMiddlewareAddon.unit.test.ts

Not sure where these tests should live nor whether it requires a change. Leaving that for you @debonte as you wrote those tests in the Python extension

DonJayamanne avatar Feb 27 '24 04:02 DonJayamanne

The LspInteractiveWindowMiddlewareAddon lives in Pylance now. It was moved over there about a year ago as part of our client refactoring work. But we left the old implementation behind in vscode-python for users on older Pylance builds. I think it's safe for vscode-python to remove this now. PR is here: https://github.com/microsoft/vscode-python/pull/22985

debonte avatar Feb 27 '24 21:02 debonte