Skip to content
This repository has been archived by the owner on Apr 14, 2022. It is now read-only.

Intellisense doesnt work for all Pytorch methods #1098

Closed
DonJayamanne opened this issue May 17, 2019 · 5 comments · Fixed by #1565
Closed

Intellisense doesnt work for all Pytorch methods #1098

DonJayamanne opened this issue May 17, 2019 · 5 comments · Fixed by #1565
Assignees
Labels
bug Something isn't working duplicate This issue or pull request already exists package: pytorch Issues specific to PyTorch

Comments

@DonJayamanne
Copy link

@Coderx7 commented on Wed May 15 2019

Environment data

  • VS Code version: 1.33.1/1.34.0
  • Extension version (available under the Extensions sidebar): 2019.4.12954
  • OS and version: Windows_NT x64 10.0.17763
  • Python version (& distribution if applicable, e.g. Anaconda): 3.6.7 Anaconda3
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): N/A
  • Relevant/affected Python packages and their versions: Pytorch 1.0.0 and 1.1.0

Expected behaviour

Intellisense should work on Pytorch methods as well but it does not!

Actual behaviour

It wont work on methods such as mm, matmul, mul, from_numpy, sum, randn, tensor, exp, empty arange, zeros, cat ,etc as described here in details.

Steps to reproduce:

  1. Simply try to use one of the aforementioned torch methods such as sum, empty,randn,tensor,etc

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

Starting Jedi Python language engine.
##########Linting Output - pylint##########
************* Module lesson4_1
9,19,error,no-member:Module 'torch' has no 'exp' member
15,11,error,no-member:Module 'torch' has no 'randn' member
16,10,error,no-member:Module 'torch' has no 'randn_like' member
17,7,error,no-member:Module 'torch' has no 'randn' member
20,4,error,no-member:Module 'torch' has no 'sum' member
23,0,error,no-member:Module 'torch' has no 'empty' member

----------------------------------------------------------------------

Your code has been rated at -11.43/10 (previous run: -11.43/10, +0.00)

@DonJayamanne commented on Thu May 16 2019

Please could you try switching to the Language Server.
Please check here for instructions microsoft/vscode-python#3977

Let me know whether this resolves the problem for you.


@Coderx7 commented on Thu May 16 2019

@DonJayamanne : I had a look at the link you provided. the problem is I cant find a way to install Language Server, as the instructions given there doesn't work for me.
I dont have a Language Server folder, to remove in first place!
This is how my extension directory looks like :
image
and this is the contents of ms-python.python folder :
image

I just updated the VSCode to the latest version couple of hours ago and this has not changed (i.e. no language server is installed)
I'd appreciate any feedback on how to get that installed so I can give you the result you need.


@DonJayamanne commented on Thu May 16 2019

All you need to do is:

Go into your settings.json, set "python.jediEnabled": false.


@Coderx7 commented on Fri May 17 2019

Thanks, I did so and language server seem to have its own share of issues, while the mentioned methods now show up in intellisense, the presentation is different and more importantly, intellisense doesnt work flawlessly here either, here is a demonstration show casing the issues:
vscode_pytorchintellisense2

(side note: jediEnabled presentation/look is much more desirable than what is being provided by language server! apart from its bugs! I myself prefer jediEnabled over language sever)


@DonJayamanne commented on Fri May 17 2019

here is a demonstration show casing the issues:

Please note, you have jedi enabled. Please change the value to false.
Once done, please provide an animated gif as done previously. Thanks a lot.


@Coderx7 commented on Fri May 17 2019

@DonJayamanne In the gif I posted above, I tested both scenarios, both with jediEnabled set to true and false!
Just watch the whole gif to the end and you'll see the difference between the two.
I start with JediEnabled and show how it works, and then disable it and show how language server works


@DonJayamanne commented on Fri May 17 2019

When using Jedi, the auto completion list is provided by an external package and we do not have much control over that. Please feel free to report an issue on their repo https://github.com/davidhalter/jedi.

On the other hand the language server is something that's built by us.
Hence I'll be moving this issue to the language server repo so they can address the issues/concerns you have.

@malmaud
Copy link

malmaud commented Jun 1, 2019

The PyTorch methods mentioned here are dynamically generated, so static analysis won't pick them up. PyTorch is now shipped with stub files which VSCode correctly uses to provide intellisense, so I think this can be closed.

@MikhailArkhipov
Copy link

Great to hear :-)

@Coderx7
Copy link

Coderx7 commented Aug 6, 2019

@malmaud : I noticed other problems as well. such as attributes/methods not showing up concerning tensors (such as data ) or in modules such as Linear, etc weights.data wont show up. therefore we lose intellisense on weights.data.
There are also issues with some modules. for example doing
import torch.nn as nn
works just fine and we have intellisense on nn but this is not the case for torch.optim and torch.cuda
meaning you cant get intellisense on torch.optim or torch.cuda and doing

import torch.optim as optim 
impor torch.cuda as cuda 

sometimes works and sometimes doesnt provide intellisense!
However if you do

from torch import optim 
from torch import cuda 

now both torch.optim, torch.cuda (in addition to optim and cuda) work!

@MikhailArkhipov
Copy link

#1301 is primary

@MikhailArkhipov MikhailArkhipov added bug Something isn't working duplicate This issue or pull request already exists labels Sep 19, 2019
@gramster gramster added the package: pytorch Issues specific to PyTorch label Sep 21, 2019
@MikhailArkhipov
Copy link

0.4.26+

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working duplicate This issue or pull request already exists package: pytorch Issues specific to PyTorch
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants