jupyter-lsp / jupyterlab-lsp

Coding assistance for JupyterLab (code navigation + hover suggestions + linters + autocompletion + rename) using Language Server Protocol
https://jupyterlab-lsp.readthedocs.io
BSD 3-Clause "New" or "Revised" License
1.8k stars 148 forks source link

jump to definition doesn't work if code deployed in conda environment other than `base` #1096

Open stellarshenson opened 2 months ago

stellarshenson commented 2 months ago

a repost from jupyterlab#16680

Description

When using jump to definition feature, while code was installed in the environment other than base, message No jump targets found is displayed. Autocompletion works fine.

When the same code is installed in base environment, jump to definition works fine.

Reproduce

  1. Have a project folder with src folder and modules in it and pyproject.toml to provide build instructions and dependencies
  2. Install this project using pip install --editable .
  3. Install nb_conda_kernels extension
  4. Create new environment with conda, call it new_env
  5. Create new notebook, import your module from src
  6. Select new_env kernel for the notebook
  7. Call function from your module, test autocompletion (should work fine)
  8. Attempt to jump to funciton definition, observe No jump targets found

Expected behavior

Module python file should be opened with the function definition to jump to. This works only if the module was installed in base environment. At the same time autocomplete works fine.

Context

It’s be easier to reproduce using the container image that I use with my data science team: https://hub.docker.com/repository/docker/stellars/stellars-jupyterlab-ds/general

It already has 3 environments: base, tensorflow and torch

Required: installed server extensions
Config dir: /home/lab/.jupyter

Config dir: /opt/conda/envs/tensorflow/etc/jupyter
    jupyter_lsp enabled
    - Validating jupyter_lsp...
      jupyter_lsp 2.2.5 OK
    jupyter_resource_usage enabled
    - Validating jupyter_resource_usage...
      jupyter_resource_usage 1.1.0 OK
    jupyter_server_mathjax enabled
    - Validating jupyter_server_mathjax...
      jupyter_server_mathjax  OK
    jupyter_server_terminals enabled
    - Validating jupyter_server_terminals...
      jupyter_server_terminals 0.5.3 OK
    jupyterlab enabled
    - Validating jupyterlab...
      jupyterlab 4.2.4 OK
    jupyterlab_git enabled
    - Validating jupyterlab_git...
      jupyterlab_git 0.50.1 OK
    nbclassic enabled
    - Validating nbclassic...
A `_jupyter_server_extension_points` function was not found in nbclassic. Instead, a `_jupyter_server_extension_paths` function was found and will be used for now. This function name will be deprecated in future releases of Jupyter Server.
      nbclassic 1.1.0 OK
    nbdime enabled
    - Validating nbdime...
      nbdime 4.0.1 OK
    notebook_shim enabled
    - Validating notebook_shim...
      notebook_shim  OK
Required: installed lab extensions
[W 2024-08-25 12:54:25.219 LabApp] 'kernel_spec_manager_class' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.
JupyterLab v4.2.4
/opt/conda/envs/tensorflow/share/jupyter/labextensions
        jupyterlab-execute-time v3.1.2 enabled OK (python, jupyterlab_execute_time)
        nbdime-jupyterlab v3.0.1 enabled OK
        jupyterlab-filesystem-access v0.6.0 enabled OK (python, jupyterlab-filesystem-access)
        jupyterlab_pygments v0.3.0 enabled OK (python, jupyterlab_pygments)
        @telamonian/theme-darcula v4.0.0 enabled OK (python, theme-darcula)
        @jupyterlab/git v0.50.1 enabled OK (python, jupyterlab-git)
        @jupyter-server/resource-usage v1.1.0 enabled OK (python, jupyter-resource-usage)
        @jupyter-lsp/jupyterlab-lsp v5.1.0 enabled OK (python, jupyterlab-lsp)
        @jupyter-widgets/jupyterlab-manager v5.0.13 enabled OK (python, jupyterlab_widgets)
        @jlab-enhanced/favorites v3.2.2 enabled OK (python, jupyterlab-favorites)

Disabled extensions:
    @jupyterlab/completer-extension:base-service
    @jupyterlab/fileeditor-extension:language-server
    @jupyterlab/lsp-extension:settings
    @jupyterlab/notebook-extension:language-server
Troubleshoot Output
troubleshoot generates too much of an output with package names, nothing important though
Command Line Output
[+] Running 2/2
 ✔ Network stellars-jupyterlab-ds_default  Created                                                                 0.0s
 ✔ Container lab-gpu                       Created                                                                 0.1s
Attaching to lab-gpu
lab-gpu  | Sun Aug 25 12:59:43 2024
lab-gpu  | +-----------------------------------------------------------------------------------------+
lab-gpu  | | NVIDIA-SMI 560.31.01              Driver Version: 560.81         CUDA Version: 12.6     |
lab-gpu  | |-----------------------------------------+------------------------+----------------------+
lab-gpu  | | GPU  Name                 Persistence-M | Bus-Id          Disp.A | Volatile Uncorr. ECC |
lab-gpu  | | Fan  Temp   Perf          Pwr:Usage/Cap |           Memory-Usage | GPU-Util  Compute M. |
lab-gpu  | |                                         |                        |               MIG M. |
lab-gpu  | |=========================================+========================+======================|
lab-gpu  | |   0  NVIDIA GeForce RTX 4090        On  |   00000000:0D:00.0  On |                  Off |
lab-gpu  | | 30%   31C    P8             22W /  450W |    1047MiB /  24564MiB |      1%      Default |
lab-gpu  | |                                         |                        |                  N/A |
lab-gpu  | +-----------------------------------------+------------------------+----------------------+
lab-gpu  |
lab-gpu  | +-----------------------------------------------------------------------------------------+
lab-gpu  | | Processes:                                                                              |
lab-gpu  | |  GPU   GI   CI        PID   Type   Process name                              GPU Memory |
lab-gpu  | |        ID   ID                                                               Usage      |
lab-gpu  | |=========================================================================================|
lab-gpu  | |    0   N/A  N/A        29      G   /Xwayland                                   N/A      |
lab-gpu  | |    0   N/A  N/A        31      G   /Xwayland                                   N/A      |
lab-gpu  | +-----------------------------------------------------------------------------------------+
lab-gpu  |
lab-gpu  | █▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█
lab-gpu  | █ Build SONS created on Thu Aug 22 21:51:58 UTC 2024                                      █
lab-gpu  | █ --------------------------------------------------------------------------------------- █
lab-gpu  | █ Running JupyterLab server on  https://localhost:8888                                    █
lab-gpu  | █ Connect VSCode to Jupyter on  https://localhost:8888/lab/tree                           █
lab-gpu  | █ Running Tensorboard server on http://localhost:6006                                     █
lab-gpu  | █ Tensorboard monitoring logs located in /tmp/tf_logs                                     █
lab-gpu  | █ Using work dir (projects) /home/lab/workspace (mount)                                   █
lab-gpu  | █ Jupyterlab settings saved to /home/lab/.jupyter                                         █
lab-gpu  | █ --------------------------------------------------------------------------------------- █
lab-gpu  | █ Visit: https://github.com/stellarshenson/stellars-jupyterlab-ds                         █
lab-gpu  | █▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█
lab-gpu  |
lab-gpu  | [I 2024-08-25 12:59:44.256 ServerApp] jupyter_lsp | extension was successfully linked.
lab-gpu  | [I 2024-08-25 12:59:44.256 ServerApp] jupyter_resource_usage | extension was successfully linked.
lab-gpu  | [I 2024-08-25 12:59:44.258 ServerApp] jupyter_server_mathjax | extension was successfully linked.
lab-gpu  | [I 2024-08-25 12:59:44.260 ServerApp] jupyter_server_terminals | extension was successfully linked.
lab-gpu  | [W 2024-08-25 12:59:44.260 LabApp] 'kernel_spec_manager_class' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.
lab-gpu  | [W 2024-08-25 12:59:44.261 LabApp] 'kernel_spec_manager_class' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.
lab-gpu  | [I 2024-08-25 12:59:44.263 ServerApp] jupyterlab | extension was successfully linked.
lab-gpu  | [I 2024-08-25 12:59:44.263 ServerApp] jupyterlab_git | extension was successfully linked.
lab-gpu  | [W 2024-08-25 12:59:44.264 NotebookApp] 'kernel_spec_manager_class' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.
lab-gpu  | [I 2024-08-25 12:59:44.266 ServerApp] nbclassic | extension was successfully linked.
lab-gpu  | [I 2024-08-25 12:59:44.266 ServerApp] nbdime | extension was successfully linked.
lab-gpu  | [I 2024-08-25 12:59:44.548 ServerApp] nb_conda | extension was found and enabled by notebook_shim. Consider moving the extension to Jupyter Server's extension paths.
lab-gpu  | [I 2024-08-25 12:59:44.548 ServerApp] nb_conda | extension was successfully linked.
lab-gpu  | [I 2024-08-25 12:59:44.548 ServerApp] notebook_shim | extension was successfully linked.
lab-gpu  | [I 2024-08-25 12:59:44.810 ServerApp] nb_conda_kernels | enabled, 3 kernels found.
lab-gpu  | [W 2024-08-25 12:59:44.814 ServerApp] Config option `password` not recognized by `PasswordIdentityProvider`.  Did you mean one of: `hashed_password, password_required`?
lab-gpu  | [I 2024-08-25 12:59:44.824 ServerApp] notebook_shim | extension was successfully loaded.
lab-gpu  | [I 2024-08-25 12:59:44.825 ServerApp] jupyter_lsp | extension was successfully loaded.
lab-gpu  | [I 2024-08-25 12:59:44.825 ServerApp] jupyter_resource_usage | extension was successfully loaded.
lab-gpu  | [I 2024-08-25 12:59:44.826 ServerApp] jupyter_server_mathjax | extension was successfully loaded.
lab-gpu  | [I 2024-08-25 12:59:44.826 ServerApp] jupyter_server_terminals | extension was successfully loaded.
lab-gpu  | [I 2024-08-25 12:59:44.834 LabApp] JupyterLab extension loaded from /opt/conda/lib/python3.11/site-packages/jupyterlab
lab-gpu  | [I 2024-08-25 12:59:44.834 LabApp] JupyterLab application directory is /opt/conda/share/jupyter/lab
lab-gpu  | [I 2024-08-25 12:59:44.834 LabApp] Extension Manager is 'pypi'.
lab-gpu  | [I 2024-08-25 12:59:44.840 ServerApp] jupyterlab | extension was successfully loaded.
lab-gpu  | [I 2024-08-25 12:59:44.843 ServerApp] jupyterlab_git | extension was successfully loaded.
lab-gpu  | [I 2024-08-25 12:59:44.844 ServerApp] [nb_conda] enabled
lab-gpu  | [I 2024-08-25 12:59:44.844 ServerApp] nb_conda | extension was successfully loaded.
lab-gpu  | [I 2024-08-25 12:59:44.846 ServerApp] nbclassic | extension was successfully loaded.
lab-gpu  | [I 2024-08-25 12:59:44.885 ServerApp] nbdime | extension was successfully loaded.
lab-gpu  | [I 2024-08-25 12:59:44.885 ServerApp] Serving notebooks from local directory: /home/lab/workspace
lab-gpu  | [I 2024-08-25 12:59:44.885 ServerApp] Jupyter Server 2.14.2 is running at:
lab-gpu  | [I 2024-08-25 12:59:44.885 ServerApp] https://localhost:8888/lab?token=...
lab-gpu  | [I 2024-08-25 12:59:44.886 ServerApp]     https://127.0.0.1:8888/lab?token=...
lab-gpu  | [I 2024-08-25 12:59:44.886 ServerApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
lab-gpu  | [I 2024-08-25 12:59:44.898 ServerApp] Skipped non-installed server(s): bash-language-server, dockerfile-language-server-nodejs, javascript-typescript-langserver, jedi-language-server, julia-language-server, pyright, python-language-server, r-languageserver, sql-language-server, texlab, typescript-language-server, unified-language-server, vscode-css-languageserver-bin, vscode-html-languageserver-bin, vscode-json-languageserver-bin, yaml-language-server
lab-gpu  |
lab-gpu  | NOTE: Using experimental fast data loading logic. To disable, pass
lab-gpu  |     "--load_fast=false" and report issues on GitHub. More details:
lab-gpu  |     https://github.com/tensorflow/tensorboard/issues/4784
lab-gpu  |
lab-gpu  | TensorBoard 2.16.2 at http://lab-gpu:6006/ (Press CTRL+C to quit)
stellarshenson commented 2 months ago

this is reposted as per request by @krassowski to move the issue from jupyterlab#16680

krassowski commented 2 months ago

This repository has a different bug report template, can you please fill it in?

stellarshenson commented 2 months ago

done, updated the report