-
Notifications
You must be signed in to change notification settings - Fork 294
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
Data viewer via debugger doesn't work in remote SSH & WSL scenarios #4065
Comments
Might this be the remote problem that Ian is working on? Oh this might mean we do need this for remote debugging because we use this for more than just the interactive window. @IanMatthewHuff I think your fix to go back to the paths for debugging may not work in all cases. |
Yeah, my current fix wouldn't clean up this issue as debugger is basically the same before and after. Normally our scenarios with debugger are blocked from being remote scenarios (Run-By-Line and IW cell debugging). The assumption here is that this is trying to open a data frame from a remote debugging session? Yeah, that would have an issue with the paths. If this is a must fix, then I could pick this up right now, I already have the setup for investigating and I'm in that area of code. |
IMO the debugger part isn't must fix as that's still behind an experiment. |
I think the issue persists. Sometimes, while I am using the debugger with data viewer:
|
Hey @edumotya, could you please provide the specific steps to reproduce the behavior you're seeing? We've been trying to track down some of these issues for a while now. For example, what debug launch configuration are you using, what source code are you debugging, and what variable are you requesting to look at? Are you debugging remotely or locally, and what platform (e.g. WSL, Linux, Windows, Mac) are you using? Thank you! |
Hi @joyceerhl, I am not able to share you the source code. On the other, I can tell you:
I am not sure... but I think it normally happens in these scenarios: Scenario 1
Scenario 2
I am sorry, but I cannot tell you much more... |
Hi team, I'm also experiencing the error edumotya ^ receives with a very similar scenario 1. MAC, Python, debug locally. Small dataframe <500 records / 10cols - so that is likely not related. It seems to occur when the DF was created in funcA, imported into funcB as an argument, and then at a breakpoint in funcB data viewer is unable to open DF. |
@khgould Are you seeing the exact same error message? Any chance you can provide a sample code repro? |
Same error here. Running in the remote Docker container in debug mode. def compute_sampling_weights(df, mode="average"): View Value in Data Viewer results in: |
Same error here, @joyceerhl , the error happens all the time if you try to inspect a Pandas dataframe while debugging Python inside a Docker container. Here is a public repo with minimalistic code to replicate it: You can run the sample.py outside Docker and see that you can inspect the dataframe 'df' perfectly well. When you debug it by running it inside Docker, it will error out. To replicate, just put a breakpoint in line 9 of sample.py, and try to view the 'df' dataframe in the Data Viewer (View Value in Data Viewer). You will get: Error: Traceback (most recent call last): File "", line 1, in NameError: name '_VSCODE_VariableImport' is not defined Hopefully this helps? We do a lot of work with Python/Pandas in Docker, so this is a big topic for us... |
@joyceerhl
I can't really share anything code related but hoping this bug will be fixed. Thank you for the effort! |
There are at least two different problems being reported in this thread.
import pandas as pd
import numpy as np
def bar(df):
return df # Trying to view this in the data viewer in a debug session triggers an error
def foo():
mydf = pd.DataFrame(np.arange(500 * 30).reshape(500, 30))
mydf = bar(mydf) # Viewing `mydf` when stopped on a breakpoint on this line works
print(mydf) # Viewing `mydf` when stopped on a breakpoint on this line works
foo() EDIT: Just did some more debugging, including more details here. That code snippet I included above doesn't repro the problem if you only put a breakpoint on the But if you set breakpoints in two separate function scopes, that's when things fall over. That made me suspect we're importing the scripts into the first function scope only (and we only do the import once because it's slow, so subsequent references in another scope fail): And sure enough, if I comment out the caching we do here and here, everything seems to work! 🤔 It does seem like the problem is that the scripts are evaluated once per debug session in a specific function scope, so the data viewer works for variables in function A, but variables in other scopes won't know anything about the imported scripts. We need to ensure we import the scripts into the global scope. |
Maybe we can skip the frame id on the eval? At least the DAP says it's allowed:
https://microsoft.github.io/debug-adapter-protocol/specification#Requests_Evaluate |
Our existing code seems like it needs to be changed because it will eval the script imports in the topmost frame at the time that the data viewer is first opened, and never again even if that frame then gets popped. But I can't seem to get global imports working. @rchiodo I think you're suggesting evaluating our Python script imports with frameId unspecified, and then evaluating the variables relative to the topmost frame ID? I tried implementing that and it doesn't work. Maybe a bug in DAP implementation. It looks like this was implemented and is supposed to work: microsoft/ptvsd#1729 The debug session customRequest implementation in VS Code seems to transparently forward the args through to the debug adapter without modification, so I've filed an issue on debugpy to get their help with investigating: microsoft/debugpy#598 In any case we can work around whatever the |
I think I have a fix for the local-only scenario involving breakpoints in two different function scopes. I created #5627 for that because it is distinct from the Docker scenario. For folks who are encountering this error locally i.e. @edumotya @MaxiTrien and @khgould, can you please try installing this VSIX and letting me know whether it solves the problem for you? https://github.com/microsoft/vscode-jupyter/suites/2575030338/artifacts/56143535 (I don't think this is going to fix the problem when running in Docker.) @rchiodo in case you're interested, omitting |
Hi I created an issue #6705 and it is marked as a dupe of this issue, but it has been nearly a year already...when will it get a chance to get fixed? Am I the only one who has this problem? |
Sorry, this is probably obvious, this isn't a high priority at the moment. We use up votes to determine what items need to be fixed. However, I just tried this with our latest and it works for me in WSL. My suspicion for your original bug was that the python extension and the jupyter extension on the WSL machine were not in sync and didn't run the expected code. |
I'm going to close this as I think the fix that @joyceerhl applied worked. At least I can't repro. |
Hi @rchiodo , thanks for the quick reply! yep, I understand the priority thing, sad that there is no more upvote for this. yeah...I still have the problem with the latest version. I think my one is related with docker. I am using WSL2, docker, python |
Thanks for reopening my old issue, however I couldn't comment on it, so have to do it here. |
There seems to be some issues with opening the data viewer from the debugger variables window still. By far the most common cause of failure is:
This suggests we're failing to eval our import scripts in the debugger somehow. No repro yet.
The text was updated successfully, but these errors were encountered: