Skip to content

Conversation

@IamtherealBrian
Copy link
Contributor

@IamtherealBrian IamtherealBrian commented Aug 21, 2024

This PR adds a flag to specify a language server for Python UDF. By default we use the pyright language server, and can switch to to the original language server called pylsp (python language server).

Key change:
-Add a flag to switch between pyright and pylsp
-Add the pyright language server

When the flag is set to use the pyright:
image

When the flag is set to use the pylsp:
image

Reason to add pyright:
-Performance on the basic language server function: Both Pyright and pylsp show comparable performance in fundamental language server functionalities, such as hover, go-to definition, and autocompletion. Thus the basic user experience remains the same regardless of the chosen language server.
-Pyright has a better ability to detect semantic errors: Pyright excels in identifying a broader range of syntax and semantic errors, particularly for code that includes type annotations. This strength makes it a valuable tool for developers who require more rigorous type checking and error detection in their Python code.

Evaluation between two language servers:
A detailed evaluation comparing the performance of two language servers on detecting basic semantic errors:
a315e35df6d225468073252e9c0cc47

Differences between two language servers:
For a more in-depth comparison of the differences between Pyright and pylsp, please refer to this discussion:
python-lsp/python-lsp-server#90

Summary:
While Pyright offers the potential for an improved user experience, especially in terms of finding semantic errors, pylsp is widely used and well-documented within its developer community. To balance the benefits of both tools, we have chosen to retain pylsp for ongoing maintenance while also introducing Pyright. This PR includes a flag that allows users to switch between the two language servers, providing flexibility based on individual project needs.

@IamtherealBrian IamtherealBrian requested a review from yunyad August 22, 2024 07:08
@IamtherealBrian IamtherealBrian self-assigned this Aug 22, 2024
Copy link
Contributor

@yunyad yunyad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM generally. I've left a few comments. However, please remove .gitignore and yarn.lock as they should not be submitted. Make only the necessary changes.

Copy link
Contributor

@yunyad yunyad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@Yicong-Huang Yicong-Huang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. The code needs some more change and please refer to the detailed comments.

For the PR description, please document the reason why we switch to pyright as the new default language server for python. The current reasoning "Its performance on detecting syntax and semantic error is better than pylsp" is too vague and maybe subjective. Please document the evaluations we did and references we found online to justify this. Make sure to use a neutral tone as this is an open source project, and comments are openly visible.

Copy link
Contributor

@Yicong-Huang Yicong-Huang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. added some minor comments in code.

@chenlica
Copy link
Contributor

chenlica commented Sep 3, 2024

We don't want to rely an external google doc for the comparison, as that URL may become obsolete. We could either include the comparison in this PR, or include it the corresponding blog. The former may be better.

Copy link
Contributor

@chenlica chenlica left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please address my comments.

@chenlica
Copy link
Contributor

chenlica commented Sep 3, 2024

We don't want to rely an external google doc for the comparison, as that URL may become obsolete. We could either include the comparison in this PR, or include it the corresponding blog. The former may be better.

We could generate a PDF for the comparison, and include the PDF in this PR, if that's allowed.

Copy link
Contributor

@chenlica chenlica left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@IamtherealBrian IamtherealBrian merged commit 2be8711 into master Sep 3, 2024
@IamtherealBrian IamtherealBrian deleted the minchongWu-pr1 branch September 3, 2024 05:26
IamtherealBrian added a commit that referenced this pull request Sep 20, 2024
… UDF action (#2811)

This PR introduces a new AI-based feature called "Add Type Annotation"
that enhances the user experience of the Python UDF on top of the
Pyright language server. The following are related PR's:
-PR for the "Add the pyright language server" :
#2797.
-PR for the "[1/3] Add AI Assistant Service - Ai Flag" :
#2808
-PR for the "[3/3] Add AI Assistant Service - add the "Add All Type
Annotation" Python UDF action" :
#2812

**Key changes:**
Added a Monaco action in the frontend Python UDF editor to allow users
to automatically add type annotations for an argument each time they
select a single argument in their code.

**Add Type Annotation:**
This action requires the user to select a single argument in their
Python UDF code. A UI with a suggestion for the selected argument will
pop up. The user can choose to accept or decline the suggestion from
OpenAI. If they accept the suggestion, it will be added to their code;
otherwise, the code will remain unchanged. The suggestion is provided by
OpenAI. After the backend receives the response from OpenAI, it will be
forwarded to the frontend via a RESTful API.

Example:



https://github.com/user-attachments/assets/29cee6c8-c793-4d83-8b27-db64bcc636ae

---------

Co-authored-by: Yicong Huang <17627829+Yicong-Huang@users.noreply.github.com>
Co-authored-by: Yicong Huang <yicong.huang@observeinc.com>
IamtherealBrian added a commit that referenced this pull request Oct 2, 2024
…thon UDF action (#2857)

This PR introduces another AI feature call "Add All Type Annotation"
that enhance the user experience of the Python UDF after integrating
with the Pyright language server. You can refer to the related PR here:
-PR for the "Add the pyright language server" :
#2797.
-PR for the "[1/3] Add AI Assistant Service - Ai Flag" :
#2808
-PR for the "[2/3] Add AI Assistant Service - add the "Add Type
Annotation" Python UDF action" :
#2811

**Key change:**
Added another Monaco action in the frontend Python UDF editor to allow
users to automatically add all type annotations for the arguments within
their selected code block.

**Add All Type Annotation:**
This action requires the user to select a code block in their Python UDF
code. The action will automatically identify all arguments without type
annotations and provide type annotation suggestions for each argument
sequentially. The selected code block will be sent to the backend for
Python Abstract Syntax Tree (AST) analysis to locate arguments without
type annotations, and the result will be sent back to the frontend via a
RESTful API. If the user selects a code block that has no arguments or
where all the arguments already have type annotations, the code will
remain unchanged.
Example:




https://github.com/user-attachments/assets/d70c1b02-b309-4359-a267-0a5eef831316
PurelyBlank pushed a commit that referenced this pull request Dec 4, 2024
This PR adds a flag to specify a language server for Python UDF. By
default we use the `pyright` language server, and can switch to to the
original language server called `pylsp` (python language server).

**Key change**:
-Add a flag to switch between `pyright` and `pylsp`
-Add the `pyright` language server

**When the flag is set to use the `pyright`**:

![image](https://github.com/user-attachments/assets/5f6d377c-93ad-40af-bd21-d1306e0e39f6)

**When the flag is set to use the `pylsp`**:

![image](https://github.com/user-attachments/assets/7fd42c30-3043-4ab4-86f3-b9bd64b10aee)

**Reason to add `pyright`**:
-Performance on the basic language server function: Both `Pyright` and
`pylsp` show comparable performance in fundamental language server
functionalities, such as hover, go-to definition, and autocompletion.
Thus the basic user experience remains the same regardless of the chosen
language server.
-Pyright has a better ability to detect semantic errors: `Pyright`
excels in identifying a broader range of syntax and semantic errors,
particularly for code that includes type annotations. This strength
makes it a valuable tool for developers who require more rigorous type
checking and error detection in their Python code.

**Evaluation between two language servers**:
A detailed evaluation comparing the performance of two language servers
on detecting basic semantic errors:

![a315e35df6d225468073252e9c0cc47](https://github.com/user-attachments/assets/67e71e37-42e1-4175-8f57-e36d60ca9db3)

**Differences between two language servers**:
For a more in-depth comparison of the differences between Pyright and
pylsp, please refer to this discussion:
python-lsp/python-lsp-server#90

**Summary**:
While `Pyright` offers the potential for an improved user experience,
especially in terms of finding semantic errors, `pylsp` is widely used
and well-documented within its developer community. To balance the
benefits of both tools, we have chosen to retain `pylsp` for ongoing
maintenance while also introducing `Pyright`. This PR includes a flag
that allows users to switch between the two language servers, providing
flexibility based on individual project needs.
PurelyBlank pushed a commit that referenced this pull request Dec 4, 2024
… UDF action (#2811)

This PR introduces a new AI-based feature called "Add Type Annotation"
that enhances the user experience of the Python UDF on top of the
Pyright language server. The following are related PR's:
-PR for the "Add the pyright language server" :
#2797.
-PR for the "[1/3] Add AI Assistant Service - Ai Flag" :
#2808
-PR for the "[3/3] Add AI Assistant Service - add the "Add All Type
Annotation" Python UDF action" :
#2812

**Key changes:**
Added a Monaco action in the frontend Python UDF editor to allow users
to automatically add type annotations for an argument each time they
select a single argument in their code.

**Add Type Annotation:**
This action requires the user to select a single argument in their
Python UDF code. A UI with a suggestion for the selected argument will
pop up. The user can choose to accept or decline the suggestion from
OpenAI. If they accept the suggestion, it will be added to their code;
otherwise, the code will remain unchanged. The suggestion is provided by
OpenAI. After the backend receives the response from OpenAI, it will be
forwarded to the frontend via a RESTful API.

Example:



https://github.com/user-attachments/assets/29cee6c8-c793-4d83-8b27-db64bcc636ae

---------

Co-authored-by: Yicong Huang <17627829+Yicong-Huang@users.noreply.github.com>
Co-authored-by: Yicong Huang <yicong.huang@observeinc.com>
PurelyBlank pushed a commit that referenced this pull request Dec 4, 2024
…thon UDF action (#2857)

This PR introduces another AI feature call "Add All Type Annotation"
that enhance the user experience of the Python UDF after integrating
with the Pyright language server. You can refer to the related PR here:
-PR for the "Add the pyright language server" :
#2797.
-PR for the "[1/3] Add AI Assistant Service - Ai Flag" :
#2808
-PR for the "[2/3] Add AI Assistant Service - add the "Add Type
Annotation" Python UDF action" :
#2811

**Key change:**
Added another Monaco action in the frontend Python UDF editor to allow
users to automatically add all type annotations for the arguments within
their selected code block.

**Add All Type Annotation:**
This action requires the user to select a code block in their Python UDF
code. The action will automatically identify all arguments without type
annotations and provide type annotation suggestions for each argument
sequentially. The selected code block will be sent to the backend for
Python Abstract Syntax Tree (AST) analysis to locate arguments without
type annotations, and the result will be sent back to the frontend via a
RESTful API. If the user selects a code block that has no arguments or
where all the arguments already have type annotations, the code will
remain unchanged.
Example:




https://github.com/user-attachments/assets/d70c1b02-b309-4359-a267-0a5eef831316
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

Successfully merging this pull request may close these issues.

4 participants