Open Scolymus opened 8 months ago
what action are you taking when you see that error? It sounds like your as_df
method isn't being added correctly (did the imported file change?), but I'm not sure why the extension's code is trying to call it.
Is that second log showing that a standard dataframe object is also failing in some way?
No, the imported file haven't changed. I never restart the laptop, and I had to do it for some updates, so I guess a new VS.code / jupyter version was updated.
To see this error I put a breakpoint and try to see the variable data. In the variables section, under "RUN AND DEBUG" section, I right click over the "as_df" property, and it lists a context menu with the option "View Value in Data Previewer", as it was doing before, but when clicking, it shows that error.
When doing the same on other pure dataframes I have seen the second log error. Interesting, there after trying to click on "View Value in Data Previewer" for a second time in the same breakpoint, before continuing, it opened the data preview.
One thing I discovered, if I do in debug terminal t = self.myobject.as_df
I can preview the t dataframe, but still not directly from self.myobject.as_df
Environment data
Expected behaviour
I have a class that derives a DataFrame (yeah, weird thing...). This object is not recognized by Jupyter to preview, and therefore we added a method called "as_df", which basically does:
Then by using this the jupyter extension was able to show the df in vs.code.
Actual behaviour
I never restart, but the other day I had to restart vs.code and now I'm getting:
Traceback (most recent call last): File "<string>", line 1, in <module> NameError: name 'as_df' is not defined. View Jupyter [log](command:jupyter.viewOutput) for further details.
I guess it updated something. I haven't tried going to a previous release of vs.code, but I tried with jupyter extension, and no luck. Also I tried to update the pandas version within the docker (I'm vieweing it from inside dev containers) and no luck neither.
Note: Sometimes I even get a message (different, attaching it in the log section) for simple df.
May it be related with ticket?
Steps to reproduce:
Create a breakpoint, and see the df variable.
Logs
Output for
Jupyter
in theOutput
panel (View
→Output
, change the drop-down the upper-right of theOutput
panel toJupyter
)``` Visual Studio Code (1.87.0, attached-container, desktop) Jupyter Extension Version: 2024.2.2024022602. Python Extension Version: 2024.2.1. Pylance Extension Version: 2024.2.3. Platform: linux (arm64). Workspace folder /code, Home = /root 11:34:15.106 [info] Start refreshing Kernel Picker (1709724855106) 11:34:15.114 [info] Using Pylance 11:34:16.589 [info] End refreshing Kernel Picker (1709724855106) 11:34:17.233 [info] Start refreshing Kernel Picker (1709724857233) 11:34:17.582 [warn] Failed to get activated env vars for /usr/local/bin/python in 319ms 11:34:17.716 [info] Process Execution: /usr/local/bin/python -c "import site;print("USER_BASE_VALUE");print(site.USER_BASE);print("USER_BASE_VALUE");" 11:34:17.788 [info] Process Execution: /usr/local/bin/python -m pip list 11:34:18.287 [info] End refreshing Kernel Picker (1709724857233) 11:36:12.720 [info] Found debugAdapterPython on Debug Configuration to use 11:36:12.746 [warn] Failed to get activated env vars for /usr/local/bin/python in 15ms 11:36:12.771 [info] Process Execution: /usr/local/bin/python -c "import pandas;print(pandas.__version__);print("5dc3a68c-e34e-4080-9c3e-2a532b2ccb4d")" 11:36:13.193 [error] Error [CodeExpectedError]: Traceback (most recent call last): File "", line 1, in
NameError: name 'as_df' is not defined
at l.Q (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:936:38118)
at vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:936:37657
11:36:13.194 [warn] DataScience Error Error [CodeExpectedError]: Traceback (most recent call last):
File "", line 1, in
NameError: name 'as_df' is not defined
at l.Q (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:936:38118)
at vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:936:37657
```
Second possible log trace (for some normal df):``` 12:14:21.798 [info] Process Execution: /usr/local/bin/python -c "import pandas;print(pandas.__version__);print("5dc3a68c-e34e-4080-9c3e-2a532b2ccb4d")" 12:14:22.208 [error] Error [CodeExpectedError]: Traceback (most recent call last): File "~/.vscode-server/extensions/ms-python.python-2024.2.1/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_comm.py", line 1195, in internal_evaluate_expression_json pydevd_vars.evaluate_expression(py_db, frame, expression, is_exec=True) File "~/.vscode-server/extensions/ms-python.python-2024.2.1/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_vars.py", line 370, in new_func return _run_with_unblock_threads(original_func, py_db, curr_thread, frame, expression, is_exec) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "~/.vscode-server/extensions/ms-python.python-2024.2.1/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_vars.py", line 334, in _run_with_unblock_threads return _run_with_interrupt_thread(original_func, py_db, curr_thread, frame, expression, is_exec) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "~/.vscode-server/extensions/ms-python.python-2024.2.1/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_vars.py", line 305, in _run_with_interrupt_thread return original_func(py_db, frame, expression, is_exec) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "~/.vscode-server/extensions/ms-python.python-2024.2.1/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_vars.py", line 548, in evaluate_expression compiled = _compile_as_exec(expression) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "~/.vscode-server/extensions/ms-python.python-2024.2.1/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_vars.py", line 412, in _compile_as_exec return compile(expression_to_evaluate, '', 'exec', _ASYNC_COMPILE_FLAGS)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 1
_VSCODE_getVariable("info", True, [0:16] )
^
SyntaxError: invalid syntax
at l.Q (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:936:38118)
at vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:936:37657
12:14:22.208 [warn] DataScience Error Error [CodeExpectedError]: Traceback (most recent call last):
File "~/.vscode-server/extensions/ms-python.python-2024.2.1/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_comm.py", line 1195, in internal_evaluate_expression_json
pydevd_vars.evaluate_expression(py_db, frame, expression, is_exec=True)
File "~/.vscode-server/extensions/ms-python.python-2024.2.1/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_vars.py", line 370, in new_func
return _run_with_unblock_threads(original_func, py_db, curr_thread, frame, expression, is_exec)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "~/.vscode-server/extensions/ms-python.python-2024.2.1/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_vars.py", line 334, in _run_with_unblock_threads
return _run_with_interrupt_thread(original_func, py_db, curr_thread, frame, expression, is_exec)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "~/.vscode-server/extensions/ms-python.python-2024.2.1/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_vars.py", line 305, in _run_with_interrupt_thread
return original_func(py_db, frame, expression, is_exec)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "~/.vscode-server/extensions/ms-python.python-2024.2.1/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_vars.py", line 548, in evaluate_expression
compiled = _compile_as_exec(expression)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "~/.vscode-server/extensions/ms-python.python-2024.2.1/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_vars.py", line 412, in _compile_as_exec
return compile(expression_to_evaluate, '', 'exec', _ASYNC_COMPILE_FLAGS)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 1
_VSCODE_getVariable("info", True, [0:16] )
^
SyntaxError: invalid syntax
at l.Q (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:936:38118)
at vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:936:37657
```