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

Pylance hints not working in Jupyter Notebook in Remote Tunnel #5071

Closed
ischurov opened this issue Nov 2, 2023 · 12 comments
Closed

Pylance hints not working in Jupyter Notebook in Remote Tunnel #5071

ischurov opened this issue Nov 2, 2023 · 12 comments
Assignees
Labels
bug Something isn't working fixed in next version (main) A fix has been implemented and will appear in an upcoming version

Comments

@ischurov
Copy link

ischurov commented Nov 2, 2023

I am using VSCode with Remote Tunnel extension to run my code on a cluster node. Current version of Pylance seem to be not working in Jupyter Notebook in this settings. Specifically, I get the following errors when trying to get Pylance hint hovering on a code item in Jupyter Notebook cell:

2023-11-02 15:52:24.392 [info] [Error - 3:52:24 PM] Request textDocument/hover failed.
2023-11-02 15:52:24.393 [info]   Message: Request textDocument/hover failed with message: Debug Failure. Unable to find notebook URI for vscode-notebook-cell://tunnel%2Bcn34/home/ischurov/tcm10/frustrations-eda/nn_supervised_reproduction.ipynb#W0sdnNjb2RlLXJlbW90ZQ%3D%3D
  Code: -32603 

Switching to pre-release version of Pylance doesn't solve this issue as in this case the Pylance server crashes.

Environment data

  • Language Server version: 2023.10.50
  • OS and version: linux x64
  • Python version (and distribution if applicable, e.g. Anaconda):
  • python.analysis.indexing: true
  • python.analysis.typeCheckingMode: basic
@github-actions github-actions bot added the needs repro Issue has not been reproduced yet label Nov 2, 2023
@debonte
Copy link
Contributor

debonte commented Nov 2, 2023

Switching to pre-release version of Pylance doesn't solve this issue as in this case the Pylance server crashes.

What crash are you seeing on 2023.10.53?

The issue you're describing above seems to be a dupe of #5037 which is fixed in 2023.10.53, so I think we need to investigate the issue you're seeing on that version instead.

@ischurov
Copy link
Author

ischurov commented Nov 2, 2023

Hi, thanks for pointing on the similar issue. Here is my Python Language Server.log under 2023.10.53: https://gist.github.com/ischurov/cf2ea5225f28af634b05ac6ab4e7c493

Note that there's still Debug Failure. Unable to find notebook URI error message, so I believe that this crash could be related to my initial issue and/or #5037.

@debonte
Copy link
Contributor

debonte commented Nov 2, 2023

@rchiodo, this looks like a repro of #5037 on 2023.10.53.

2023-11-02 18:17:03.311 [info] [Error - 6:17:03 PM] Server process exited with code 1.
2023-11-02 18:17:03.316 [info] [Info  - 6:17:03 PM] Connection to server got closed. Server will restart.
2023-11-02 18:17:03.316 [info] true
2023-11-02 18:17:03.920 [info] [Info  - 6:17:03 PM] (1475304) Pylance language server 2023.10.53 (pyright d7012d0d) starting
2023-11-02 18:17:03.920 [info] [Info  - 6:17:03 PM] (1475304) Server root directory: /home/ischurov/.vscode-server/extensions/ms-python.vscode-pylance-2023.10.53/dist
2023-11-02 18:17:03.933 [info] [Info  - 6:17:03 PM] (1475304) Starting service instance "frustrations-eda"
2023-11-02 18:17:03.985 [info] [Info  - 6:17:03 PM] (1475304) Setting pythonPath for service "frustrations-eda": "/nix/store/525hx0cz3k0s2nya7r7rai9s4rr5q4kd-python3-3.10.12-env/bin/python3"
2023-11-02 18:17:03.985 [info] [Info  - 6:17:03 PM] (1475304) Setting environmentName for service "frustrations-eda": "3.10.12 (global)"
2023-11-02 18:17:04.049 [info] [Info  - 6:17:04 PM] (1475304) Assuming Python version 3.10
2023-11-02 18:17:04.809 [info] [Info  - 6:17:04 PM] (1475304) Found 112 source files
2023-11-02 18:17:04.909 [info] [Info  - 6:17:04 PM] (1475304) Starting service instance "frustrations-eda"
2023-11-02 18:17:05.055 [info] [Info  - 6:17:05 PM] (1475304) Setting pythonPath for service "frustrations-eda": "/nix/store/525hx0cz3k0s2nya7r7rai9s4rr5q4kd-python3-3.10.12-env/bin/python3.10"
2023-11-02 18:17:05.055 [info] [Info  - 6:17:05 PM] (1475304) Setting environmentName for service "frustrations-eda": "3.10.12 (global)"
2023-11-02 18:17:05.115 [info] [Info  - 6:17:05 PM] (1475304) Assuming Python version 3.10
2023-11-02 18:17:05.511 [info] [Info  - 6:17:05 PM] (1475304) Found 112 source files
2023-11-02 18:17:09.079 [info] [Info  - 6:17:09 PM] (1475304) [BG(1)] Long operation: checking: /vol/tcm10/ischurov/frustrations-eda/fourier_scaling.py (2420ms)
2023-11-02 18:17:09.079 [info] [Info  - 6:17:09 PM] (1475304) [BG(1)] Long operation: analyzing: /vol/tcm10/ischurov/frustrations-eda/fourier_scaling.py (3551ms)
2023-11-02 18:17:09.459 [info] [Info  - 6:17:09 PM] (1475304) [BG(3)] Long operation: checking: /vol/tcm10/ischurov/frustrations-eda/fourier_scaling.py (2444ms)
2023-11-02 18:17:09.460 [info] [Info  - 6:17:09 PM] (1475304) [BG(3)] Long operation: analyzing: /vol/tcm10/ischurov/frustrations-eda/fourier_scaling.py (3457ms)
...
2023-11-02 18:17:09.500 [info]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             ^
Error: Debug Failure. Unable to find notebook URI for /home/ischurov/tcm10/frustrations-eda/nn_supervised_reproduction.ipynb#W0sdnNjb2RlLXJlbW90ZQ%3D%3D.py
    at _0xbf34b3.getNotebookCellUri (/home/ischurov/.vscode-server/extensions/ms-python.vscode-pylance-2023.10.53/dist/server.bundle.js:1:253889)
    at _0x1c8f27.getUri (/home/ischurov/.vscode-server/extensions/ms-python.vscode-pylance-2023.10.53/dist/server.bundle.js:1:218340)
    at t.convertPathToUri (/home/ischurov/.vscode-server/extensions/ms-python.vscode-pylance-2023.10.53/dist/pyright.bundle.js:1:1107502)
    at _0x42211f.convertDiagnostics (/home/ischurov/.vscode-server/extensions/ms-python.vscode-pylance-2023.10.53/dist/pyright.bundle.js:1:1159499)
    at _0x42211f.convertDiagnostics (/home/ischurov/.vscode-server/extensions/ms-python.vscode-pylance-2023.10.53/dist/server.bundle.js:1:909918)
    at /home/ischurov/.vscode-server/extensions/ms-python.vscode-pylance-2023.10.53/dist/pyright.bundle.js:1:1159741
    at Array.forEach (<anonymous>)
    at _0x42211f.onAnalysisCompletedHandler (/home/ischurov/.vscode-server/extensions/ms-python.vscode-pylance-2023.10.53/dist/pyright.bundle.js:1:1159663)
    at /home/ischurov/.vscode-server/extensions/ms-python.vscode-pylance-2023.10.53/dist/server.bundle.js:1:910333

@rchiodo
Copy link
Contributor

rchiodo commented Nov 2, 2023

I think we're going to need more logging information then. Not sure how this would happen in 2023.10.53.

@ischurov
Copy link
Author

ischurov commented Nov 2, 2023

Sure, what kind of logs do you need?

@rchiodo
Copy link
Contributor

rchiodo commented Nov 2, 2023

This would probably help:

"python.trace.server": "verbose"

That makes VS code log all of the messages it sends to us and what our response is. I can then see why we wouldn't know about the notebook URI.

Our latest may fix this though (which should come out sometime today). We stopped interpreting notebook cell URIs and just keep them around.

@chrizonix
Copy link

Can confirm, error is still not (fully) fixed in v2023.11.11. Last working version for me is v2023.10.40.

Info about environment

Pylance v2023.11.11
Python v2023.21.13071013
Jupyter v2023.10.1003070148
Databricks Power Tools v2.2.3

We run an Azure Databricks "Remote Edit" Tool called "Databricks Power Tools", and I still get no "syntax-highlighting or Intelli-Sense" for Python Notebooks with v2023.11.11.

Logs

2023-11-03 16:12:39.165 [info] (Client) Pylance async client (2023.11.11) started with python extension (2023.21.13071013) [f48aa2579ede0090c915c9f38b9a710c65ec47c903c5646334fd8e3d9724a048]
2023-11-03 16:12:43.749 [info] [Info  - 4:12:43 PM] (21100) Pylance language server 2023.11.11 (pyright 64c9c3ff) starting
2023-11-03 16:12:43.856 [info] [Info  - 4:12:43 PM] (21100) Server root directory: C:\Users\user\.vscode\extensions\ms-python.vscode-pylance-2023.11.11\dist
2023-11-03 16:12:43.858 [info] [Info  - 4:12:43 PM] (21100) Starting service instance "Test"
2023-11-03 16:12:43.859 [info] [Info  - 4:12:43 PM] (21100) virtual workspace: wsfs:/
2023-11-03 16:12:43.873 [info] [Info  - 4:12:43 PM] (21100) Starting service instance "Databricks - Workspace"
2023-11-03 16:12:44.164 [info] [Info  - 4:12:44 PM] (21100) Setting pythonPath for service "Test": "C:\Dev\Python310\python.exe"
2023-11-03 16:12:44.165 [info] [Info  - 4:12:44 PM] (21100) Setting environmentName for service "Test": "3.10.0 (global)"
2023-11-03 16:12:45.654 [info] [Info  - 4:12:45 PM] (21100) Assuming Python version 3.10
2023-11-03 16:12:47.977 [info] [Info  - 4:12:47 PM] (21100) No source files found.
2023-11-03 16:12:48.231 [info] [Info  - 4:12:48 PM] (21100) Setting pythonPath for service "Databricks - Workspace": "C:\ProgramData\miniconda3\python.exe"
2023-11-03 16:12:48.231 [info] [Info  - 4:12:48 PM] (21100) Setting environmentName for service "Databricks - Workspace": "3.10.10 (base conda)"
2023-11-03 16:12:50.589 [info] [Info  - 4:12:50 PM] (21100) Assuming Python version 3.10
2023-11-03 16:12:51.935 [info] [Error - 4:12:51 PM] (21100) File or directory "wsfs:" does not exist.
2023-11-03 16:12:51.936 [info] [Info  - 4:12:51 PM] (21100) No source files found.
2023-11-03 16:12:52.122 [info] FEHLER: Der Prozess "18092" wurde nicht gefunden.

2023-11-03 16:13:01.813 [info] [Info  - 4:13:01 PM] (21100) virtual workspace: wsfs:/
2023-11-03 16:13:01.840 [info] [Info  - 4:13:01 PM] (21100) Starting service instance "Databricks - Workspace"
2023-11-03 16:13:07.478 [info] FEHLER: Der Prozess "20688" wurde nicht gefunden.

2023-11-03 16:13:07.484 [info] [Info  - 4:13:07 PM] (21100) Setting environmentName for service "Databricks - Workspace": "3.10.10 (base conda)"
2023-11-03 16:13:09.343 [info] [Error - 4:13:09 PM] (21100) File or directory "wsfs:" does not exist.
2023-11-03 16:13:11.242 [info] [Info  - 4:13:11 PM] (21100) No source files found.
2023-11-03 16:13:59.889 [info] Error: Debug Failure. Cell path not found for cell vscode-notebook-cell:/Users/user%40domain.net/Test.ipynb#W0sd3Nmcw%3D%3D
    at _0x5e8922.getNotebookCellPath (c:\Users\user\.vscode\extensions\ms-python.vscode-pylance-2023.11.11\dist\server.bundle.js:1:261668)
    at _0x8f195a.decodeTextDocumentUri (c:\Users\user\.vscode\extensions\ms-python.vscode-pylance-2023.11.11\dist\server.bundle.js:1:230980)
    at c:\Users\user\.vscode\extensions\ms-python.vscode-pylance-2023.11.11\dist\server.bundle.js:1:953531
    at Array.map (<anonymous>)
    at _0x68314f.<computed> (c:\Users\user\.vscode\extensions\ms-python.vscode-pylance-2023.11.11\dist\server.bundle.js:1:953475)
    at _0x45a7e7._onDidOpenNotebookDocumentAsync (c:\Users\user\.vscode\extensions\ms-python.vscode-pylance-2023.11.11\dist\server.bundle.js:1:933069)

2023-11-03 16:13:59.893 [info] [Error - 4:13:59 PM] Request textDocument/documentHighlight failed.
2023-11-03 16:13:59.893 [info]   Message: Request textDocument/documentHighlight failed with message: Debug Failure. Cell path not found for cell vscode-notebook-cell:/Users/user%40domain.net/Test.ipynb#W0sd3Nmcw%3D%3D
  Code: -32603 

Side note

The Path /Users/user%40domain.net/Test.ipynb does not "really" exist on the Windows Filesystem.
It's a "virtual" path created by Databricks Power Tools (this creates a "virtual remote workspace" for Azure Databricks).

Maybe this is the reason?

Workaround

Downgrade to v2023.10.40. Works fine with Databricks!

Bug Introduction

I did a small "git bisect" and found the error to be introduced in v2023.10.41.
Maybe a code compare between v2023.10.40 and v2023.10.41 might be beneficial.

Hope this helps :)

@rchiodo
Copy link
Contributor

rchiodo commented Nov 3, 2023

@chrizonix can you turn this setting on, reproduce the problem, and upload the output of the 'Python Language Server' tab again?

"python.trace.server": "verbose"

That should output of the contents of the 'notebookDocument/didOpen' message. It's what we use to find the 'path' to the notebook from a cell.

@chrizonix
Copy link

chrizonix commented Nov 3, 2023

Hi @rchiodo,

Thanks for looking into this issue! This was a wild ride, but I was able to reproduce the issue.

Good news first, error does not occur on v2023.11.10.
I was only able to reproduce the error on v2023.11.11 (on this version the server even crashes).

Steps to reproduce (for v2023.11.11)

  1. Open a Jupyter Notebook on an Azure Databricks Workspace (using Databricks Power Tools)
  2. Pylance Server starting in the background, after some while syntax highlighting appears (pylance is working)
  3. Ctrl+Click on a Python package or function (e.g. on an import package line)
  4. VSCode jumps to the definition in a new tab
  5. Go back to the original file, VSCode does a refresh of the syntax highlighting
  6. Pylance crashes
2023-11-03 18:00:58.019 [info] [Error - 6:00:58 PM] Client Pylance: connection to server is erroring.
write EPIPE
2023-11-03 18:00:58.023 [info] [Error - 6:00:58 PM] Server process exited with code 1.
2023-11-03 18:00:58.047 [info] [Info  - 6:00:58 PM] Connection to server got closed. Server will restart.

Full logs here github.com/chrizonix/pylance-test/pylance-log-v2023.11.11.txt.zip

@rchiodo
Copy link
Contributor

rchiodo commented Nov 3, 2023

Thanks that helps. It looks like a document close event is happening after the notebook change event that indicates the cell was removed. We were removing the cell from the map during the notebook change event, but we need to keep it around.

@rchiodo
Copy link
Contributor

rchiodo commented Nov 3, 2023

Repro steps for me:

  1. Open VS code from WSL
  2. Create a new notebook
  3. Create a cell
  4. Deselect the code
  5. Hit 'dd'
  6. Hit 'z'
  7. Repeat until crash

@rchiodo rchiodo assigned rchiodo and unassigned KacieKK Nov 3, 2023
@rchiodo rchiodo added bug Something isn't working and removed needs repro Issue has not been reproduced yet labels Nov 3, 2023
@PylanceBot PylanceBot added the fixed in next version (main) A fix has been implemented and will appear in an upcoming version label Nov 3, 2023
@bschnurr
Copy link
Member

bschnurr commented Nov 9, 2023

This issue has been fixed in prerelease version 2023.11.12, which we've just released. You can find the changelog here: CHANGELOG.md

@bschnurr bschnurr closed this as completed Nov 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed in next version (main) A fix has been implemented and will appear in an upcoming version
Projects
None yet
Development

No branches or pull requests

7 participants