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

Use Python extension API to get environments related to Notebooks/IW #1857

Closed
wants to merge 149 commits into from

Conversation

DonJayamanne
Copy link
Owner

See microsoft/vscode-jupyter#15987

Should also fix microsoft/vscode-jupyter#16112
Should also avoid Pylance having to monitor notebook changes and then trying to figure out the Environment for a Notebook.

@rchiodo @heejaechang Please can you let me know if this works
I.e. going forward (we can plan how we roll this out)

  • Pylance can use just Python extension API to get Python environment for a Uri (the uri can be a Notebook or IW uri)
  • If the kernel is changed, the event onDidChangeActiveEnvironmentPath will be triggered with the corresponding Uri
  • If a kernel is changed to say a Non Python Kernel, then its triggered again, but the active interpreter for that Uri will be the same as the worksapce interpreter

I believe this should simplify things.
@karrtikr /cc

DonJayamanne and others added 30 commits July 4, 2024 20:52
Co-authored-by: Rafał <23004737+rafrafek@users.noreply.github.com>
In this PR:
- Disabling run submenu on Chat code blocks by passing `!inChat` to the
sub run menu condition
- Enabling the "Restart Python Language Server" command for Jupyter
notebooks by adding `notebookType == jupyter-notebook` to its context
key
Set justMyCode only in the python debugger, not in the python extension.
Closed: microsoft/vscode-python-debugger#335
Closes #23719

---------

Co-authored-by: Don Jayamanne <Don.Jayamanne@microsoft.com>
karthiknadig and others added 29 commits October 4, 2024 08:23
…endtext. (#24248)

For some reason, it seems like shell integration may take awhile to get
activated: #24239

Performance issue seemed to indicate exactly 3 second coming from the
https://github.com/microsoft/vscode-python/pull/24078/files#diff-5290f3097d5f92e3495c8abfbe095dff83c3f8de3dcac08ab2d0304f71bb412fR93,
so lets try reducing this to 0.5 second and let user fall back to
sendText. We may need further investigate why
onDidChangeTerminalShellIntegration may be taking awhile.
…4250)

Resolves: #24122
Related: #24190,
#24127

I think the culprit was we were not passing in interpreter when we call
createActivatedEnvironment.
Addressing issue #24226

This adds a way to customize the timeout for the interpreter info script
to run, by customizing the duration of the
`VSC_PYTHON_INTERPRETER_INFO_TIMEOUT` environment variable.

This is to address setups (e.g. a monorepo with Bazel) where the hard
coded 15 seconds is insufficient, as the first Python run also includes
additional setup work to ensure the venv is available for use before the
interpreter can actually execute.

This is being done via env var instead of via a VS Code setting to avoid
introducing additional settings that will be deprecated after other
planned upcoming work on interpreter discovery (see discussion on
24226).
This PR changes some setting tags as follows:

- Remove the experimental tag from the `python.missingPackage.severity`
setting considering the setting does not seem to be experimental and
that the setting does not seem to be part of any experiment.
- Add the onExP tag onto the `python.locator` setting considering the
setting is both experimental (based on its description) and part of an
experiment.
- Change the experimental tag to preview for
`python.terminal.shellIntegration.enabled`, considering it is a
non-stable setting that does not seem to be part of an experiment.
- Add the onExP tag to `python.REPL.sendToNativeREPL` considering it is
part of an experiment.
Fixes #24077

Removes redundant type annotations from JSDocs in TypeScript files where
the type is already inferred by TypeScript.

For example:

![image](https://github.com/user-attachments/assets/9ee1f0b6-f36f-4f4f-81dc-5178d46808cb)

Here I removed JSDoc types but I still kept all the useful information. 
I tried to be on the liberal side to avoid removing any comments that
provide useful context or clarify behavior. If I missed any or if more
can be removed, I’m happy to go over it again.

Additionally, if this issue only applies to a specific folder or scope,
please let me know so I can make the necessary adjustments.
```
2024-10-05 15:12:00.813 [error]   File "c:\Users\User\.vscode\extensions\ms-python.python-2024.16.0-win32-x64\python_files\python_server.py", line 162
    while line := STDIN.readline().strip():
                ^
SyntaxError: invalid syntax

2024-10-05 15:12:00.816 [error] Python server exited with code 1
2024-10-05 15:14:46.427 [error] Error getting response from REPL server: [k [Error]: Connection is closed.
	at pe (c:\Users\User\.vscode\extensions\ms-python.python-2024.16.0-win32-x64\out\client\extension.js:2:2053423)
	at Object.sendRequest (c:\Users\User\.vscode\extensions\ms-python.python-2024.16.0-win32-x64\out\client\extension.js:2:2055781)
	at g.executeCode (c:\Users\User\.vscode\extensions\ms-python.python-2024.16.0-win32-x64\out\client\extension.js:2:799948)
	at g.execute (c:\Users\User\.vscode\extensions\ms-python.python-2024.16.0-win32-x64\out\client\extension.js:2:799770)
	at u.value (c:\Users\User\.vscode\extensions\ms-python.python-2024.16.0-win32-x64\out\client\extension.js:2:829806)
	at i.executeHandler (c:\Users\User\.vscode\extensions\ms-python.python-2024.16.0-win32-x64\out\client\extension.js:2:805190)
	at bb.$executeCells (file:///c:/Users/User/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:155:24084)
	at Zb.S (file:///c:/Users/User/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:31:113896)
	at Zb.Q (file:///c:/Users/User/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:31:113676)
	at Zb.M (file:///c:/Users/User/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:31:112765)
	at Zb.L (file:///c:/Users/User/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:31:111870)
	at gh.value (file:///c:/Users/User/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:31:110667)
	at T.B (file:///c:/Users/User/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:29:732)
	at T.fire (file:///c:/Users/User/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:29:950)
	at no.fire (file:///c:/Users/User/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:31:9399)
	at gh.value (file:///c:/Users/User/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:174:13273)
	at T.B (file:///c:/Users/User/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:29:732)
	at T.fire (file:///c:/Users/User/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:29:950)
	at no.fire (file:///c:/Users/User/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:31:9399)
	at MessagePortMain.<anonymous> (file:///c:/Users/User/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:174:11562)
	at MessagePortMain.emit (node:events:519:28)
	at MessagePortMain._internalPort.emit (node:electron/js2c/utility_init:2:2619)] {
  code: 1
}
```
this error message is more specific than the generic "doesn't recognize
argument `--cov=.`" and will help point users in the right direction to
knowing how to enable coverage.
Once at a time I switched to jedi language server but find it didn't
work.

I checked the error and find that the error was:
```
  File "***data\extensions\ms-python.python-2024.16.1-universal\python_files\lib\jedilsp\jedi\inference\__init__.py", line 91, in __init__
    self.grammar = environment.get_grammar()
                   ~~~~~~~~~~~~~~~~~~~~~~~^^
  File "***data\extensions\ms-python.python-2024.16.1-universal\python_files\lib\jedilsp\jedi\cache.py", line 112, in wrapper
    result = method(self, *args, **kwargs)
  File "***data\extensions\ms-python.python-2024.16.1-universal\python_files\lib\jedilsp\jedi\api\environment.py", line 37, in get_grammar
    return parso.load_grammar(version=version_string)
           ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
  File "***data\extensions\ms-python.python-2024.16.1-universal\python_files\lib\jedilsp\parso\grammar.py", line 264, in load_grammar
    raise NotImplementedError(message)
NotImplementedError: Python version 3.13 is currently not supported.
```

I tracked down and find that parso 0.8.4 added python3.13 support

So the dependencies needs to be updated
Resolves: #24339

---------

Co-authored-by: Karthik Nadig <kanadig@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Choosing a kernel for the first time does not cause a kernel change event