Python Lanaguage Server not working in Code Studio

kai_fang
kai_fang Registered Posts: 7 ✭✭

We recently start to integrate Code Studio into our dataiku instance, and we realize that the Code Studio seem not to enable language server for python code and color the code and raise warning for bug. Jump to definition is still working even though the code is not colored.

Is there any specific setup we need to have so as to enable python lanaguage server to work, or Code studio does not support that yet.

Best,

Kai

Operating system used: Linux

Answers

  • JordanB
    JordanB Dataiker, Dataiku DSS Core Designer, Dataiku DSS Adv Designer, Registered Posts: 295 Dataiker

    Hi @kai_fang,

    Through the extensions tab in Visual Studio, you should be able to search for @installed and see that Python is installed, which includes a default python language server. You can also install pylint, python debugger, autopep8 and others.

  • kai_fang
    kai_fang Registered Posts: 7 ✭✭

    Thanks @JordanB, confirm that we do have python extension installed, but language server is not working with it.

  • Turribeach
    Turribeach Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2023 Posts: 1,925 Neuron
    edited July 23

    @JordanB This is not working properly. I work with Kai and I have raised a ticket with support already (#70393) but here is a quick demostration of the issue. In this first image I show some sample code with Visual Studio Code (VSC) running in DSS vs Visual Studio Code (VSC) running on Windows:

    You can see that while VSC in DSS has some syntax colouring it's only selecting reserved words whereas in VSC on Windows you have methods, variables, etc. Furthermore I can double click on "environ" and it shows me it's a variable. Amd finally the dummy kk import is shown as missing. None of this works in VSC in DSS. Then I turn my VSC on Windows language server setting to None and I get this:

    Now it's exactly the same basic syntax colouring aside from import being blue in VSC DSS and purple in VSC on Windows. So this clearly indicates the language server is not working for us.

  • kai_fang
    kai_fang Registered Posts: 7 ✭✭

    So further investigation shows the following error:

    when I restart my pylance lanaguage server


    2024-07-30 14:43:54.322 [info] node:internal/modules/cjs/loader:1029
    throw err;
    ^

    Error: Cannot find module '/home/dataiku/workspace/dist/server.bundle.js'
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1026:15)
    at Function.Module._load (node:internal/modules/cjs/loader:871:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:22:47 {
    code: 'MODULE_NOT_FOUND',
    requireStack: []
    }

    The python extension we use is version v2024.0.1

    It seems that additional setup like installing npm is required to get the language server working?

    @JordanB

  • JordanB
    JordanB Dataiker, Dataiku DSS Core Designer, Dataiku DSS Adv Designer, Registered Posts: 295 Dataiker

    @kai_fang

    My tests show that the Python language support extension is working correctly.


    Also, I can highlight the existing modules and check for a brief description:

    While we can't see it when we disable the extension:

    Regarding pylance, please note that this extension is not available through the Extensions Market place in VS Code on K8s, so I don't expect it to work correctly even if you install it.

    Please see the reference documentation for code server (The one that uses CS on K8s):

    Though code-server takes the open-source core of VS Code and allows you to run it in the browser, it is not entirely equivalent to Microsoft's VS Code.One major difference is in regards to extensions and the marketplace. The core of VS code is open source, while the marketplace and many published Microsoft extensions are not. Furthermore, Microsoft prohibits the use of any non-Microsoft VS Code from accessing their marketplace. Per the Terms of Service:
    

    I don't think you'll be able to use this extension in VSCode, and if you do, you'll most likely face issues like the one you are having now, as VS Code is not completely equivalent to a code server.  https://coder.com/docs/code-server/FAQ#why-cant-code-server-use-microsofts-extension-marketplace

  • JordanB
    JordanB Dataiker, Dataiku DSS Core Designer, Dataiku DSS Adv Designer, Registered Posts: 295 Dataiker

    I would recommend removing pylance and only use the pre-installed extensions. As is explained here, the marketplace is simply different:

    Because of this, we can't offer any extensions on Microsoft's marketplace. Instead, we use the Open-VSX extension gallery, which is also used by various other forks. It isn't perfect, but its getting better by the day with more and more extensions.
    

Setup Info
    Tags
      Help me…