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

Feature: open data viewer from debug variables view #131

Closed
amunger opened this issue Feb 6, 2024 · 23 comments
Closed

Feature: open data viewer from debug variables view #131

amunger opened this issue Feb 6, 2024 · 23 comments
Labels
feature Feature request

Comments

@amunger
Copy link

amunger commented Feb 6, 2024

There is a new proposed API that would enable the data wrangler extension to contribute its data visualizer for specific variables listed in the debug variables view: https://github.com/microsoft/vscode/blob/b62def4ceb2fe7c0a31908e98e76586d4a191285/src/vscode-dts/vscode.proposed.debugVisualization.d.ts#L1

With a sample implementation here:
https://github.com/microsoft/vscode-extension-samples/tree/connor4312/debug-viz-demo/proposed-api-sample

If that API wouldn't work for some reason, I'm sure @connor4312 would be happy to have your feedback.

@pwang347
Copy link
Member

pwang347 commented Feb 7, 2024

Hi @connor4312, it would be great to have this integrated for Data Wrangler.

I wanted to check with you: is the runtime environment exposed for the debugging context or do visualizers only have access to the serialized values?

Data Wrangler works primarily with Pandas DataFrame objects so if it is the latter we would at least need a full representation (e.g. pickled format) to be able to parse it properly. Not too sure if that would be feasible yet for perf reasons. Of course, we would ideally like access to the full runtime environment (ie. a REPL where we can run Python code) but from what I'm seeing that doesn't seem to be available.

Thanks!

@connor4312
Copy link
Member

connor4312 commented Feb 7, 2024

is the runtime environment exposed for the debugging context or do visualizers only have access to the serialized values?

You can see more of a description here microsoft/vscode#197287 (comment)

  • The "when" clause in the package.json gives you approximate matching on the variable to avoid having to activate the extension when it's not required
  • Then the DebugVisualizationProvider is called is called with more details from DAP, as well as the DebugSession, in its context. You can interact with the debugger or do anything you need to here, and set any command to run either in the provide or resolve method. You should defer any expensive work to the "resolve" method as that's only called once the user selects your visualizer in the UI.

@pwang347
Copy link
Member

pwang347 commented Feb 8, 2024

Got it, thanks for the details. I will need to play around with it some more, but tentatively it seems like we can evaluate arbitrary expressions with setExpression which is something. We will also need to think more on our side how we want the user experience for this to be.

@pwang347 pwang347 added the feature Feature request label Feb 10, 2024
@pwang347
Copy link
Member

related: #49

@amunger
Copy link
Author

amunger commented Feb 16, 2024

After looking into this area more, I don't think the new proposed API is required and you should be able to just contribute to the debug context menu:

"debug/variables/context": [
      {
          "command": "extension.showDataViewer",
          "group": "1_view",
          "when": "DebugSessionSupportsDataViewer"
      }
  ],

Where DebugSessionSupportsDataViewer is a context key that you would update by watching vscode.debug.onActiveDebugSessionChanged, and checking if that debug session is compatible.

The new API is more targeted towards extensions that want to provide a way to display the variable value within the variable view itself.

@gkocjan
Copy link

gkocjan commented May 8, 2024

Is there a chance we can implement this feature? Right now, many people are using DataViewer in debug mode from the Jupyter Extension, but it just said that this feature is deprecated in favour of Data Wrangler.

@pwang347
Copy link
Member

pwang347 commented May 9, 2024

Hi @gkocjan, note that it is possible already to use Data Wrangler while debugging in both the stable and pre-release versions (any of the following entrypoints should work):
image

However, specifically for this button in the debug panel

image

... it's something that still needs to be hooked up. You can track the progress on it here: microsoft/vscode-jupyter#15680

Thanks!

@juanbretti
Copy link

juanbretti commented May 9, 2024

Hello @pwang347 .
What you are proposing, is while using iPython (interactive Python), Jupyter Notebook or interactive Window.

Standard Python Script

When executing a standard Python Script (.py), this option is not available.
For example, when debugging this file using this feature:

image

I get:

image

There is only this option:

image

And no other variables inspector.

Using interactive Python

When using interactive Python interpreter, there is the option:

image

Here is the action when clicking the "Show variable snapshot in data view":

image

What is missing

What is missing is the ability to use the Data Wrangler when debugging a Python Script, while using the standard compiler.
What do you think?

Code used:

# %%
import pandas as pd

# Creating a dictionary with sample data
data = {
    'Name': ['John', 'Anna', 'Peter', 'Linda', 'Mark'],
    'Age': [25, 30, 35, 28, 40],
    'City': ['New York', 'Paris', 'London', 'Tokyo', 'Sydney'],
    'Salary': [50000, 60000, 70000, 55000, 65000]
}

# Creating DataFrame
df = pd.DataFrame(data)

# %%
print(df)

# %%

@pwang347
Copy link
Member

pwang347 commented May 9, 2024

Hi @juanbretti, thank you for sharing more about your use case!

Just to confirm, I found that the "View Value in Data Viewer" button only appears if you have the Jupyter extension installed but it isn't present otherwise (e.g. if you disable the Jupyter extension). Let me know if my steps below are the same as yours:

Starting the debugger
image

With extension
image

Without
image

If having the Jupyter extension installed is not a problem for you, then this issue should address your ask: microsoft/vscode-jupyter#15680

Otherwise, if you want to support this functionality for pure Python without any IPython dependency it would be good to open a new GitHub issue and continue the discussion there. Thanks!

@juanbretti
Copy link

@pwang347 , thank you for your prompt response.
I do have installed the extensions:

  • Jupyter
  • Data Wrangler
  • Python
  • Python Debugger

When I debug using:

image

I do see:

image

But this option, opens:

image

Which is not the "Data Wrangler" variable inspector.

Does it work the same way for you too?

@pwang347
Copy link
Member

pwang347 commented May 9, 2024

Hi @juanbretti, yes that is the way it works for me as well. I meant to say that the viewer you see is coming from the Jupyter extension currently, so there is technically a dependency on IPython (to my understanding). If that is not an issue to you, the missing functionality you described should be resolved soon from the Jupyter side. Hope this helps!

Edit: to clarify, this will also require a change in the DW extension. I will let you know when both changes are available.

@7Eric9
Copy link

7Eric9 commented May 14, 2024

can't wait to use this feature!!!

@gkocjan
Copy link

gkocjan commented May 14, 2024

#131 (comment)
My point was that the Jupyter extension showed a message that DataViewer is deprecated in favour of DataWrangler, and there is the missing feature of debugging pure .py scripts that was really well shown by @juanbretti here: #131 (comment)

TLDR: it would be great to use Data Wrangler from a pure Python script debugging window because it gives many more features

@pwang347
Copy link
Member

Hi all! Support for the debug variables entrypoint (for both .py and .ipynb files) is now released in VS Code Insiders.

You can give it a try with the following extension versions:

  • Jupyter: v2024.5.2024052401 (pre-release)
  • Data Wrangler: v1.1.2 (pre-release)

Note that this feature will also be available in the Stable version around early June. Thanks again for using Data Wrangler and for contributing to the discussion!

@7Eric9
Copy link

7Eric9 commented May 28, 2024

@pwang347 I didn't find the entry for a pure .py in pre-release 1.1.2, did I missed sth? like configuration etc...

image

Maybe I should switch my vsocde from stable to insider?

@juanbretti
Copy link

Maybe I should switch my vsocde from stable to insider?

Yes, as mentioned before by @pwang347 , you need to try Visual Studio Code Insiders.

@pwang347
Copy link
Member

pwang347 commented May 28, 2024

Hi @7Eric9! Yes, that is correct. If you would like to try out the experience now, you will need to use VS Code Insiders (see link shared by @juanbretti).

For a bit of explanation, this is because the Jupyter prerelease version needed above (v2024.5.2024052401) depends on the latest VS Code Insiders version, which is not yet available in VS Code Stable (but will be in about a week).

@edumoros
Copy link

edumoros commented Jul 8, 2024

Hello @pwang347, do you know when this feature will be available in VS Code Stable? You mentioned that it should be in early June, but I haven't seen it in the last version

@pwang347
Copy link
Member

pwang347 commented Jul 8, 2024

Hello @pwang347, do you know when this feature will be available in VS Code Stable? You mentioned that it should be in early June, but I haven't seen it in the last version

Hi @edumoros! It is working for me on the following latest stable versions:

  • VS Code Stable: 1.91.0
  • Data Wrangler Extension: 1.4.1
  • Jupyter Extension: 2024.6.0

Could you please double-check if the same configuration above works for you?

@edumoros
Copy link

edumoros commented Jul 8, 2024

Hi @pwang347! I have those same versions, but it's not working for me.

Screenshot 2024-07-08 at 20 38 31

@pwang347
Copy link
Member

pwang347 commented Jul 8, 2024

@edumoros That's odd, could you please double check that the Data Wrangler extension is not disabled? For example, by checking the extension page here:
image

image

If Data Wrangler is not disabled, I would recommend opening an issue here: https://github.com/microsoft/vscode-jupyter/issues

Since the Data Viewer is being routed by the Jupyter extension and you should not see the old one if you have Data Wrangler installed. Another thing that might be worth checking is whether you are able to open the Data Wrangler viewer from debugging a .ipynb file. Thanks!

@Huanyu-Liu
Copy link

Huanyu-Liu commented Jul 9, 2024

i am using the same versions here, but it's very unstable.
Sometimes it works, but most of the time it will direct to the data wrangle extension after clicking view value in data viewer. Neither the data viewer or data wrangler window opens now.

VS Code Stable: 1.91.0
Data Wrangler Extension: 1.4.1
Jupyter Extension: 2024.6.0

image

@pwang347
Copy link
Member

pwang347 commented Jul 9, 2024

@Huanyu-Liu Hi! The launch delegation is currently happening on the Jupyter extension side, could you please open an issue in the Jupyter extension repository?

It would be great if you can provide short example code to reproduce the issue. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Feature request
Projects
None yet
Development

No branches or pull requests

8 participants