Closed amunger closed 1 month ago
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!
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 https://github.com/microsoft/vscode/issues/197287#issuecomment-1899409209
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.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.
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.
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.
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):
However, specifically for this button in the debug panel
... it's something that still needs to be hooked up. You can track the progress on it here: https://github.com/microsoft/vscode-jupyter/issues/15680
Thanks!
Hello @pwang347 . What you are proposing, is while using iPython (interactive Python), Jupyter Notebook or interactive Window.
When executing a standard Python Script (.py), this option is not available. For example, when debugging this file using this feature:
I get:
There is only this option:
And no other variables inspector.
When using interactive Python interpreter, there is the option:
Here is the action when clicking the "Show variable snapshot in data view":
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?
# %%
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)
# %%
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
With extension
Without
If having the Jupyter extension installed is not a problem for you, then this issue should address your ask: https://github.com/microsoft/vscode-jupyter/issues/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!
@pwang347 , thank you for your prompt response. I do have installed the extensions:
When I debug using:
I do see:
But this option, opens:
Which is not the "Data Wrangler" variable inspector.
Does it work the same way for you too?
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.
can't wait to use this feature!!!
https://github.com/microsoft/vscode-data-wrangler/issues/131#issuecomment-2099977714 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: https://github.com/microsoft/vscode-data-wrangler/issues/131#issuecomment-2103109736
TLDR: it would be great to use Data Wrangler from a pure Python script debugging window because it gives many more features
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:
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!
@pwang347 I didn't find the entry for a pure .py in pre-release 1.1.2, did I missed sth? like configuration etc...
Maybe I should switch my vsocde from stable to insider?
Maybe I should switch my vsocde from stable to insider?
Yes, as mentioned before by @pwang347 , you need to try Visual Studio Code Insiders.
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).
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
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:
Could you please double-check if the same configuration above works for you?
Hi @pwang347! I have those same versions, but it's not working for me.
@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:
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!
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
@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!
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.