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

Argument suggestions for some functions in the pytorch module are duplicated when using Jedi #12503

Closed
CatNofishing opened this issue Jun 23, 2020 · 25 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster

Comments

@CatNofishing
Copy link

image

Reproduce

import time
import torch
from torch import nn, optim
import sys
import d2lzh_pytorch as d2l

device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')


def nin_block(in_channels, out_channels, kernel_size, stride, padding):
    blk = nn.Sequential(
        nn.Conv2d(in_channels, out_channels, kernel_size, stride, pad)
    )
@CatNofishing CatNofishing added data science bug Issue identified by VS Code Team member as probable bug labels Jun 23, 2020
@CatNofishing CatNofishing changed the title Code snippets for some functions in the pytorch module are duplicated Code snippets for some functions in the pytorch module are duplicated when use Jedi Jun 23, 2020
@CatNofishing CatNofishing changed the title Code snippets for some functions in the pytorch module are duplicated when use Jedi Code snippets for some functions in the pytorch module are duplicated when using Jedi Jun 23, 2020
@ghost ghost added the triage-needed Needs assignment to the proper sub-team label Jun 23, 2020
@ghost ghost removed the triage-needed Needs assignment to the proper sub-team label Jun 24, 2020
@CatNofishing
Copy link
Author

CatNofishing commented Jun 26, 2020

version: 1.46.1 (user setup)
commit: cd9ea6488829f560dc949a8b2fb789f3cdc05f5d
date: 2020-06-17T21:13:20.174Z
Electron: 7.3.1
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Windows_NT x64 10.0.18363

language server: use Jedi

This is definitely a bug, many function parameter prompts will have duplicate snippets In standard and third-party libraries.
😂😂😂
image
image

@ericsnowcurrently ericsnowcurrently changed the title Code snippets for some functions in the pytorch module are duplicated when using Jedi Argument suggestions for some functions in the pytorch module are duplicated when using Jedi Jun 30, 2020
@ericsnowcurrently
Copy link
Member

@CatNofishing, thanks for letting us know about this. What happens when you use the language server? (In your settings.json, set 'python.languageServer": "Microsoft".)

@ericsnowcurrently ericsnowcurrently added the info-needed Issue requires more information from poster label Jun 30, 2020
@CatNofishing
Copy link
Author

@ericsnowcurrently Microsoft language server does not have this problem, but some function parameter suggestions are wrong. For example print(sep=)
image

@ericsnowcurrently
Copy link
Member

Thanks for checking that. We'd definitely like to resolve any problems you've had with the language server. To that end, I recommend opening a separate issue to address that directly.

If you also want to keep using Jedi then we can investigate further. (Otherwise we can close this issue.) I suspect that Jedi is returning multiple results due to some sort of overloading criteria (possibly due to type annotations), though it might also be a bug in Jedi (or the Python extension). Just keep in mind that our ability to address issues in Jedi is limited.

Either way, you might also consider contacting the Jedi project directly, to get a faster resolution. I've always found @davidhalter to be responsive, helpful, and committed to the success of his project.

@davidhalter
Copy link

What version of Jedi are you using currently?

It would be interesting to see the results with the latest version. If that happens there as well, it would be clearly a bug. (Happy to fix that ASAP).

@CatNofishing
Copy link
Author

@davidhalter Thank you for your reply, the jedi version I used is 0.15.2. Vscode is also the latest version😁.
@ericsnowcurrently Thank you for your suggestion, but now I prefer Jedi😂, because LSP will occupy a lot of memory and CPU. I hope you can keep track of Jedi and make further investigations.

@davidhalter
Copy link

@CatNofishing Can you upgrade to Jedi 0.17.1? It should probably mostly work (and be quite a bit better). If it does not work there I would have to investigate.

@ericsnowcurrently
Copy link
Member

@CatNofishing, the Python extension ships with a vendored copy of Jedi, located in "[])https://code.visualstudio.com/docs/editor/extension-gallery#_where-are-extensions-installed)/pythonFiles/lib/python/" and uses that install explicitly for completions, etc. when configured to use Jedi. So to use a newer version you will need to manually replace the vendored copy with the newer one:

#PYEXT_DIR=~/.vscode/extensions/ms-python.python-$(code --list-extensions --show-versions | grep ms-python.python | awk -F'@' '{print $2}')
cd $PYEXT_DIR/pythonFiles/lib
mv jedi jedi.orig
python3 -m pip install --target . jedi

Doing that is fine as a one-off to see if the newer Jedi fixes the problem, but the proper solution is for the Python extension to update the vendored copy.

So if you feel up to manually installing the newer Jedi version, please give it a try. Otherwise we'll need to investigate further on our end. Either way, please let us know. Thanks!

@CatNofishing
Copy link
Author

@davidhalter @ericsnowcurrently I upgraded jedi to 0.17.1 through the pip command and set the jedi path in vscode, but the parameter suggestion still has duplicate fragments.

image
image
image
image

@davidhalter
Copy link

Can you run this?

>>> jedi.Script('import os\nos.path.join(p').complete()
[<Completion: path=>, <Completion: PendingDeprecationWarning>, <Completion: PermissionError>, <Completion: pow>, <Completion: print>, <Completion: ProcessLookupError>, <Completion: property>]
>>> jedi.Script('print(sep)').complete(column=9, fuzzy=True)
[<Completion: BaseException>, <Completion: sep=>]

If you get the same output, then VSCode is might be using Jedi wrong. The mistake might be that they add keyword params as completions, when in fact Jedi does that already by itself (so it results in the repeated entries).

@CatNofishing
Copy link
Author

image
Thanks for your reply, now I have to turn to Pylance as an alternative. 😂

@davidhalter
Copy link

You have to use 0.17.1 to use complete.

@davidhalter
Copy link

Can you try again with 0.17.1? Or use the old API jedi.Script('print(sep)', column=9).complete()?

@CatNofishing
Copy link
Author

@davidhalter Thanks your reply!😁
image
I got the same output as you, it seems to be a problem with vscode

@CatNofishing
Copy link
Author

@ericsnowcurrently @karthiknadig This problem still exists, do you have any plans to fix this problem, otherwise, I can only use pylance as an alternative.

@byehack
Copy link

byehack commented Aug 7, 2020

same here ...

@CatNofishing
Copy link
Author

@ericsnowcurrently please figure this issue😂,this problem seriously affects the development of jedi.

@karthiknadig karthiknadig added investigating We are looking into the cause of the issue and removed triage labels Sep 15, 2020
@DavidKutu DavidKutu removed the info-needed Issue requires more information from poster label Sep 24, 2020
@kimadeline
Copy link

Hi @CatNofishing,

Is this issue still happening?

@kimadeline kimadeline added info-needed Issue requires more information from poster triage and removed investigating We are looking into the cause of the issue labels Mar 24, 2021
@CatNofishing
Copy link
Author

image
Yeap,still happening🙃

@karthiknadig
Copy link
Member

@CatNofishing Try with languageServer=JediLSP.

@CatNofishing
Copy link
Author

CatNofishing commented Mar 25, 2021

Okay, it works better than jedi , but worse than pylance😥

@davidhalter
Copy link

Okay, it works better than jedi , but worse than pylance

Interested to hear why that is :) Are the completions better? Is it faster? What's the difference?

@CatNofishing
Copy link
Author

CatNofishing commented Mar 26, 2021

😂For pandas and numpy, the speed of pylance intelligent prompt is slightly faster than Jedi when you first import these library. Sometimes Jedi has a delay when you first imports the library,and need to wait for the smart prompt to loading,once the smart prompt is loaded, Jedi will be very fast.And pylance has no problem of duplicate parameters in vscode. But i prefer parameter prompt layout style in Jedi [https://github.com/microsoft/pylance-release/issues/301]

@davidhalter
Copy link

For pandas and numpy, the speed of pylance intelligent prompt is slightly faster than Jedi when you first import these library. Sometimes Jedi has a delay when you first imports the library,and need to wait for the smart prompt to loading,once the smart prompt is loaded, Jedi will be very fast.

Oh yes, that's unfortunately a known problem (davidhalter/jedi#1059). Rest assured I'm working on something. It just might take a lot of time, but I'm pretty sure it will be help a lot.

@kimadeline
Copy link

Closing since it works with JediLSP.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 28, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

8 participants