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

Dataviewer fails when builtins are overridden with user variables #10941

Closed
1 of 2 tasks
WillCoulterKorrus opened this issue Jul 26, 2022 · 5 comments · Fixed by #10988
Closed
1 of 2 tasks

Dataviewer fails when builtins are overridden with user variables #10941

WillCoulterKorrus opened this issue Jul 26, 2022 · 5 comments · Fixed by #10988
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug data-viewer verified Verification succeeded
Milestone

Comments

@WillCoulterKorrus
Copy link

WillCoulterKorrus commented Jul 26, 2022

Applies To

  • Notebooks (.ipynb files)
  • Interactive Window and/or Cell Scripts (.py files with #%% markers)

What happened?

Pre-amble:
Data viewer fails if you ever re-assign a default class as a variable. There is no warning to avoid doing so, either in "Black", "Pylint", or in the jupyter extension failure error.
This only happens when vs code is launched via github desktop by right clicking the repo name --> "open in VS Code".
The data viewer simply becomes empty if you do the following but open VS Code via anaconda navigator.

Any of these lines placed anywhere in a jupyter .ipynb file cause the data viewer creation error.

list = 1
dict = 3
tuple =3

Expected Result:
I expected to have a new "Data Viewer - var_name" appear as a new window.

Result:
I received the error pop-up, ""Failed to create the Data Viewer. Check the Jupyter tab of the Output window for more info.".
The entire output log of jupyter is pasted below when opening VS Code via github desktop and running on a script within that repo.

Minimally-Reproducible Example:

  1. Launch vscode via Github Desktop / Anaconda Navigator (I don't think this matters)
  2. Create a two-line .ipynb script
some_list = [1,2,3,4]
list = 2
  1. Restart Jupyter kernel
  2. Run script
  3. Go to "JUPYTER: VARIABLES" window tab
  4. Click the "show variable in data viewer" button
    6a) If VS Code was opened via github desktop:
    image

6b) If VS Code was opened via anaconda navigator:
image

VS Code Version

Version: 1.69.2 (user setup) Commit: 3b889b090b5ad5793f524b5d1d39fda662b96a2a Date: 2022-07-18T16:12:52.460Z Electron: 18.3.5 Chromium: 100.0.4896.160 Node.js: 16.13.2 V8: 10.0.139.17-electron.0 OS: Windows_NT x64 10.0.19043

Jupyter Extension Version

v2022.6.1201981810

Jupyter logs

info 14:28:37.558: Execute Cell 0 c:\Users\William.coulter\Documents\example_jupyter_dataviewer_fail.ipynb
info 14:28:37.623: Cell 0 executed with state Success
info 14:29:9.833: Executing silently Code (idle) = def _VSCODE_getVariable(what_to_get, is_debugging, *args):\n# Query Jupyter server for the info
info 14:29:9.875: Executing silently Code (completed) = def _VSCODE_getVariable(what_to_get, is_debugging, *args):\n# Query Jupyter server for the info with 1 output(s)
info 14:29:11.294: Loading webview. View is notset
info 14:29:11.295: Loading web view...
info 14:29:11.296: Webview panel created.
info 14:29:11.381: Process Execution: > ~\Anaconda3\python.exe -c "import pandas;print(pandas.__version__)"
> ~\Anaconda3\python.exe -c "import pandas;print(pandas.__version__)"
info 14:29:11.410: Executing silently Code (idle) = def _VSCODE_getVariable(what_to_get, is_debugging, *args):\n# Query Jupyter server for the info
info 14:29:11.410: Executing silently Code (idle) = def _VSCODE_getVariable(what_to_get, is_debugging, *args):\n# Query Jupyter server for the info
info 14:29:11.437: Executing silently Code (completed) = def _VSCODE_getVariable(what_to_get, is_debugging, *args):\n# Query Jupyter server for the info with 1 output(s)
info 14:29:11.465: Executing silently Code (completed) = def _VSCODE_getVariable(what_to_get, is_debugging, *args):\n# Query Jupyter server for the info with 1 output(s)
info 14:29:11.645: Web view react rendered
info 14:29:12.139: Executing silently Code (idle) = def _VSCODE_getDataFrame(what_to_get, is_debugging, *args):\nimport pandas as _VSCODE_pd\nimp
info 14:29:12.831: Executing silently Code (completed) = def _VSCODE_getDataFrame(what_to_get, is_debugging, *args):\nimport pandas as _VSCODE_pd\nimp with 0 output(s)
error 14:29:12.831: [Error: Failed to fetch variable info from the Jupyter server.
	at g.extractJupyterResultText (c:\Users\William.coulter\.vscode\extensions\ms-toolsai.jupyter-2022.6.1201981810\out\extension.node.js:24:299215)
	at g.deserializeJupyterResult (c:\Users\William.coulter\.vscode\extensions\ms-toolsai.jupyter-2022.6.1201981810\out\extension.node.js:24:299313)
	at getDataFrameInfo (c:\Users\William.coulter\.vscode\extensions\ms-toolsai.jupyter-2022.6.1201981810\out\extension.node.js:24:296311)
	at async r.ensureInitialized (c:\Users\William.coulter\.vscode\extensions\ms-toolsai.jupyter-2022.6.1201981810\out\extension.node.js:39:283280)
	at async r.getDataFrameInfo (c:\Users\William.coulter\.vscode\extensions\ms-toolsai.jupyter-2022.6.1201981810\out\extension.node.js:39:282040)
	at async E.prepDataFrameInfo (c:\Users\William.coulter\.vscode\extensions\ms-toolsai.jupyter-2022.6.1201981810\out\extension.node.js:39:267659)
	at async E.showData (c:\Users\William.coulter\.vscode\extensions\ms-toolsai.jupyter-2022.6.1201981810\out\extension.node.js:39:265433)
	at async f.create (c:\Users\William.coulter\.vscode\extensions\ms-toolsai.jupyter-2022.6.1201981810\out\extension.node.js:39:279718)]

Coding Language and Runtime Version

No response

Language Extension Version (if applicable)

v2022.10.1

Anaconda Version (if applicable)

2.2.0

Running Jupyter locally or remotely?

Local

@WillCoulterKorrus WillCoulterKorrus added bug Issue identified by VS Code Team member as probable bug triage-needed Issue needs to be triaged labels Jul 26, 2022
@rchiodo
Copy link
Contributor

rchiodo commented Jul 26, 2022

Thanks for the issue.

We might be able to detect this and put up a warning. I think this would more an error for a linter to detect though.

@WillCoulterKorrus
Copy link
Author

Thanks for the issue.

We might be able to detect this and put up a warning. I think this would more an error for a linter to detect though.

No problem! I'm migrating from Matlab to Python, so it's a struggle to get all of these pieces (linter, formatting, github repo, visual code studio, anaconda, python interpreter in vs code) all working, let alone understand them fully.

I just saw the error code appear and thought I should mention the headache I went through. I'm using Pylint (because that's most popular I guess), so should I post this issue there?

@rchiodo
Copy link
Contributor

rchiodo commented Jul 26, 2022

I just saw the error code appear and thought I should mention the headache I went through. I'm using Pylint (because that's most popular I guess), so should I post this issue there?

Yeah that would probably be a better place to capture this. This would mess up other things too (not just dataframe viewing) that would be more generic to all python code.

@DonJayamanne
Copy link
Contributor

I think we should use the builtin alias _VSCODE_builtins instead of just using list, dict, etc. We ran into similar issues in the past and used an alias for referencing these builtins, i think we haven't completed that work, list and a few others are still pointing to the globally imported items, instead of the scoped alias _VSCODE_builtins.
Same applies to str, range & others.

@WillCoulterKorrus
Copy link
Author

Yeah that would probably be a better place to capture this. This would mess up other things too (not just dataframe viewing) that would be more generic to all python code.

Ok, I'll post it there. I was surprised to find there was no warning for overriding standard classes!
I don't know how it is causing a problem with vs code jupyter, but we could probably agree that "Failed to fetch variable info from the Jupyter server" is fairly misleading.". Maybe there could be some guidance on how to track down the issue. Maybe there are many paths leading to the error.

Anyway, I'll post on Pylint. I'm impressed with the fast responses!

@rebornix rebornix assigned DonJayamanne and unassigned rchiodo Jul 28, 2022
@rebornix rebornix added data-viewer and removed triage-needed Issue needs to be triaged labels Jul 28, 2022
@DonJayamanne DonJayamanne added this to the August 2022 milestone Jul 31, 2022
@DonJayamanne DonJayamanne changed the title Creation of dataviewer fails if base python class names are reassigned as a variable after launching from github desktop Dataviewer fails when builtins are overridden with user variables Aug 2, 2022
@roblourens roblourens added the verified Verification succeeded label Aug 24, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 25, 2023
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 data-viewer verified Verification succeeded
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants