kedro-org / vscode-kedro

Kedro extension for VSCode including LSP and other features
https://marketplace.visualstudio.com/items?itemName=kedro.Kedro
Apache License 2.0
11 stars 2 forks source link

Crashing on multi-root VSCode workspace #10

Open Calychas opened 1 month ago

Calychas commented 1 month ago

Hi! First of all, thank you for creating this extension!

I have a problem with enabling it on multi-root VSCode workspace. I have one project with Kedro (installed in venv) and multiple of other projects (each with its own venv) without it.

The extension works correctly if I open one project directly.

Here are the logs from the beginning. I redacted it, but the important part is that its choosing the other project without Kedro - the 29th project in the workspace file (it's not first even alphabetically). The first entry is the one with Kedro:

2024-05-15 11:01:30.212 [info] Name: Kedro
2024-05-15 11:01:30.212 [info] Module: kedro
2024-05-15 11:01:30.212 [info] Python extension loading
2024-05-15 11:01:30.212 [info] Python Interpreter: 
2024-05-15 11:01:30.212 [info] Waiting for interpreter from python extension.
2024-05-15 11:01:30.212 [info] Python extension loaded
2024-05-15 11:01:30.230 [info] Server run command: /Users/kacper.lesniara/Projects/<the_other_project_without_kedro>/venv/bin/python /Users/kacper.lesniara/.vscode/extensions/kedro.kedro-0.0.3/bundled/tool/lsp_server.py
2024-05-15 11:01:30.231 [info] Server: Start requested.
2024-05-15 11:01:31.479 [info] Traceback (most recent call last):
  File "/Users/kacper.lesniara/.vscode/extensions/kedro.kedro-0.0.3/bundled/tool/lsp_server.py", line 17, in <module>

2024-05-15 11:01:31.479 [info]     from kedro.config import OmegaConfigLoader
ModuleNotFoundError: No module named 'kedro'

Here are the error logs from the end:

2024-05-15 12:40:20.562 [info] [Error - 12:40:20] Client Kedro: connection to server is erroring. Shutting down server.
2024-05-15 12:40:20.562 [info] [Error - 12:40:20] Stopping server failed
2024-05-15 12:40:20.562 [info] Error: Client is not running and can't be stopped. It's current state is: starting
    at w.shutdown (/Users/kacper.lesniara/.vscode/extensions/kedro.kedro-0.0.3/dist/webpack:/Kedro/node_modules/vscode-languageclient/lib/common/client.js:914:29)
    at w._serverProcess (/Users/kacper.lesniara/.vscode/extensions/kedro.kedro-0.0.3/dist/webpack:/Kedro/node_modules/vscode-languageclient/lib/common/client.js:889:30)
    at w.stop (/Users/kacper.lesniara/.vscode/extensions/kedro.kedro-0.0.3/dist/webpack:/Kedro/node_modules/vscode-languageclient/lib/node/main.js:152:38)
    at w.handleConnectionError (/Users/kacper.lesniara/.vscode/extensions/kedro.kedro-0.0.3/dist/webpack:/Kedro/node_modules/vscode-languageclient/lib/common/client.js:1147:67)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
2024-05-15 12:40:20.562 [info] [Error - 12:40:20] Server initialization failed.
2024-05-15 12:40:20.562 [info]   Message: write EPIPE
  Code: -32099 
2024-05-15 12:40:20.562 [info] [Error - 12:40:20] Kedro client: couldn't create connection to server.
2024-05-15 12:40:20.562 [info]   Message: write EPIPE
  Code: -32099 
2024-05-15 12:40:20.562 [info] [Error - 12:40:20] Restarting server failed
2024-05-15 12:40:20.562 [info]   Message: write EPIPE
  Code: -32099 
2024-05-15 12:40:20.563 [info] [Info  - 12:40:20] Connection to server got closed. Server will restart.
2024-05-15 12:40:20.563 [info] true
2024-05-15 12:40:20.590 [info] Traceback (most recent call last):
  File "/Users/kacper.lesniara/.vscode/extensions/kedro.kedro-0.0.3/bundled/tool/lsp_server.py", line 17, in <module>

2024-05-15 12:40:20.590 [info]     from kedro.config import OmegaConfigLoader
ModuleNotFoundError: No module named 'kedro'

2024-05-15 12:40:20.594 [info] [Error - 12:40:20] Client Kedro: connection to server is erroring. Shutting down server.
2024-05-15 12:40:20.594 [info] [Error - 12:40:20] Stopping server failed
2024-05-15 12:40:20.594 [info] Error: Client is not running and can't be stopped. It's current state is: starting
    at w.shutdown (/Users/kacper.lesniara/.vscode/extensions/kedro.kedro-0.0.3/dist/webpack:/Kedro/node_modules/vscode-languageclient/lib/common/client.js:914:29)
    at w._serverProcess (/Users/kacper.lesniara/.vscode/extensions/kedro.kedro-0.0.3/dist/webpack:/Kedro/node_modules/vscode-languageclient/lib/common/client.js:889:30)
    at w.stop (/Users/kacper.lesniara/.vscode/extensions/kedro.kedro-0.0.3/dist/webpack:/Kedro/node_modules/vscode-languageclient/lib/node/main.js:152:38)
    at w.handleConnectionError (/Users/kacper.lesniara/.vscode/extensions/kedro.kedro-0.0.3/dist/webpack:/Kedro/node_modules/vscode-languageclient/lib/common/client.js:1147:67)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
2024-05-15 12:40:20.594 [info] [Error - 12:40:20] Server initialization failed.
2024-05-15 12:40:20.594 [info]   Message: write EPIPE
  Code: -32099 
2024-05-15 12:40:20.594 [info] [Error - 12:40:20] Kedro client: couldn't create connection to server.
2024-05-15 12:40:20.594 [info]   Message: write EPIPE
  Code: -32099 
2024-05-15 12:40:20.594 [info] [Error - 12:40:20] Restarting server failed
2024-05-15 12:40:20.594 [info]   Message: write EPIPE
  Code: -32099 
2024-05-15 12:40:20.595 [info] [Error - 12:40:20] The Kedro server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.

Going into the project's .py files to activate the Python extension (to have the correct venv selected) and running kedro: Restart Server doesn't help.

Workaround: I supplied the kedro.interpreter at the workspace level to point to the project's python executable with Kedro, restarted VSCode and it works. However, as this is a global solution (for the entire workspace), if I had multiple kedro, kedro-datasets versions across different projects some things may break potentially?

Potential fix / implementation: Use kedro from the particular project's venv. Spin up multiple kedro-servers (one per project if needed). For inspiration - see how the mypy extension works. By default it uses global mypy, but specifying mypy.runUsingActiveInterpreter to true on a project-level enables using locally installed mypy

Info: kedro == 0.19.5 python == 3.10.11 vscode-kedro == 0.0.3 Apple M2

astrojuanlu commented 1 month ago

Thanks @Calychas for reporting this issue! It looks like that's enough information for us to try to reproduce. We'll get back to you soon.