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

Jupyter Integration? #55

Closed
ccowin opened this issue Jan 20, 2021 · 4 comments
Closed

Jupyter Integration? #55

ccowin opened this issue Jan 20, 2021 · 4 comments

Comments

@ccowin
Copy link

ccowin commented Jan 20, 2021

Hello,

First apologies if this isn't the place to ask this question, but I couldn't find anywhere better to ask. I was just hoping to get a better understanding of how to implement this package into Jupyter. I have a Jupyterhub server that uses @krassowski/jupyterlab-lsp. It lists jedi-language-server as experimental but wanted to give it a try. I uninstalled pyls and installed jedi-language-server, but I'm pretty sure the settings I have are wrong, but I have absolutely no idea what they should be and there is no example anywhere that I can find. The jupyterlab-lsp always just says additional servers needed.

I grabbed the settings here: https://github.com/pappasam/coc-jedi and tried in a dozen different ways based off of how the pyls package's settings were done, but nothing really worked.

Does anyone know what settings I need to enter for jupyterlab-lsp to detect the jedi-language-server?

I was able to find this from here:

c.LanguageServerManager.language_servers = {
    "jedi-language-server": {
        "argv": ["jedi-language-server"],
        "languages": ["python"],
        "version": 2
    }
}
c.LanguageServerManager.autodetect = False

So assuming I need to add that to some file in jupyter --paths?

This documentation says it should be in /etc/jupyter/jupyter_server_config.d/jupyter_server_config.py but that doesn't exist.

@pappasam
Copy link
Owner

Hmm, it seems like jupyter-lsp now natively supports jedi-language-server: https://github.com/krassowski/jupyterlab-lsp/blob/a06e806a283d941eb09e775ee3e33e5433cd133f/python_packages/jupyter_lsp/jupyter_lsp/specs/jedi_language_server.py.

This was merged 4 days ago. My guess is that if you upgrade jupyterlab-lsp to the latest release (v3.1.0) and have installed jedi-language-server, jedi-language-server should be auto-detected without requiring you to configure anything.

Note: I'm not an active Jupyter user, so the above suggestions are educated guesses. Happy to help though, and do let me know if that works for you!

@krassowski
Copy link
Contributor

Hi @ccowin , maintainer of jupyterlab-lsp here, indeed the jedi-language-server should be autodetected if installed in the same environment as JupyterLab. This is only available in the new latest version that requires JupyterLab 3.0, but can be also used with jupyterlab-classic if you prefer the old jupyter notebook-like experience.

If there is a problem after installing the latest version (please remember to restart JupyterLab after installation of everything), please do open a bug report issue over in the jupyterlab-lsp repository providing your environment details as requested in "Context" part of the template.

Of note, the basic diagnostics offered by jedi-language-server will not work at present (as pygls returns null where it should not) but a workaround (https://github.com/krassowski/jupyterlab-lsp/pull/485) will be present in the next release (v3.1.1 to be released later this week).

@pappasam thanks for handling this and for maintaining this language server! It does feel nice and responsive - I am looking forward to using it as a daily driver and to implementing more features in the Jupyter client integration extension (super excited about your codeAction support!).

@krassowski
Copy link
Contributor

krassowski commented Jan 21, 2021

A quick note as I now see that you are a JupyterHub user: you need to configure your JupyterHub to use the new jupyter_server rather than notebook as a backend. This is documented in both JupyterHub documentation and mentioned at our side, but many users seem to overlook the jupyter_server requirement. See:

In short, the Jupyter ecosystem is transitioning to the new infrastructure and the JupyterHub release cycle lead to users being trapped in a transitioning state in which they still can install JupyterLab using and its frontend extensions the legacy architecture, but the backend extensions are not being picked up for the most part as they assume the new infrastructure is already present.

Cross-referencing: jupyterhub/jupyterhub#3340

@ccowin
Copy link
Author

ccowin commented Jan 21, 2021

Yes! Thank you, I figured it had something to do with it being a JupyterHub server. There is always one little thing that needs to be changed when following documentation designed for Lab or Notebook. Even more specifically I use The Littlest JupyterHub so for that use case specifically I made a file with:

c.Spawner.environment = {
    'JUPYTERHUB_SINGLEUSER_APP': "jupyter_server.serverapp.ServerApp"
}

in:
/opt/tljh/config/jupyterhub_config.d/jupyterhub_config.py
but I imagine a stock jupyterhub install's file structure is pretty similar.

Thank you both @pappasam and @krassowski; I really appreciate your work, willingness to help and your timely responses!
I eagerly await the fix for diagnostics!

@ccowin ccowin closed this as completed Jan 21, 2021
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

No branches or pull requests

3 participants