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

The representation of a variable introspected in the Debug Console can be clipped on VSCode. #162965

Open
zljubisic opened this issue Oct 6, 2022 · 17 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug debug Debug viewlet, configurations, breakpoints, adapter issues debug-console
Milestone

Comments

@zljubisic
Copy link

Type: Bug

Please look at the picture:

image

In case you need it:

df = pd.DataFrame(
    [
        ['A', 'short text', 1],
        ['A', '1 very 2 very 3 very 4 very 5 very 6 very 7 very 8 very 9 very 10 very text', 2],
        ['A', 'not so long text', 3],
    ], columns=['first', 'description', 'last']
)
df
  first                                        description  last
0     A                                         short text     1
1     A  1 very 2 very 3 very 4 very 5 very 6 very 7 ve...     2
2     A                                   not so long text     3
len(df)
3
df.iloc[-1]
first                         A
description    not so long text
last                          3
Name: 2, dtype: object
pd.options.display.max_colwidth = None
df
  first                                        description  last
0     A                                         short text     1
1     A  1 very 2 very 3 very 4 very 5 very 6 very 7 ve...     2
2     A                                   not so long text     3
df['not existing column']
Traceback (most recent call last):
  File "/home/vagrant/miniconda3/envs/42-proposal-create-a-new-use-case-for-power-savings/lib/python3.8/site-packages/pandas/core/indexes/base.py", line 3621, in get_loc
    return self._engine.get_loc(casted_key)
  File "pandas/_libs/index.pyx", line 136, in pandas._libs.index.IndexEngine.get_loc
  File "pandas/_libs/index.pyx", line 163, in pandas._libs.index.IndexEngine.get_loc
  File "pandas/_libs/hashtable_class_helper.pxi", line 5198, in pandas._libs.hashtable.PyObjectHashTable.get_item
  File "pandas/_libs/hashtable_class_helper.pxi", line 5206, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'not existing column'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/vagrant/miniconda3/envs/42-proposal-create-a-new-use-case-for-power-savings/lib/python3.8/site-packages/pandas/core/frame.py", line 3505, in __getitem__
    indexer = self.columns.get_loc(key)
  File "/home/vagrant/miniconda3/envs/42-proposal-create-a-new-use-case-for-power-savings/lib/python3.8/site-packages/pandas/core/indexes/base.py", line 3623, in get_loc
    raise KeyError(key) from err
KeyError: 'not existing column'

Extension version: 2022.14.0
VS Code version: Code 1.71.2 (74b1f97, 2022-09-14T21:03:37.738Z)
OS version: Windows_NT x64 10.0.19042
Modes:
Sandboxed: No
Remote OS version: Linux x64 3.10.0-1127.el7.x86_64

@karthiknadig karthiknadig transferred this issue from microsoft/vscode-python Oct 6, 2022
@fabioz
Copy link
Contributor

fabioz commented Oct 6, 2022

This seems like a layout issue in the debug console in VSCode itself.

At least I cannot reproduce it here (see image below).

@zljubisic can you provide the logs for your use case when you execute those in your version just so that I'm sure that this is the case?

See: https://github.com/microsoft/debugpy/wiki/Enable-debugger-logs for details on how to collect the logs.

@karthiknadig if this turns out being an issue in VSCode, can we move the ticket to the VSCode repository or should a new issue be created (maybe just referencing this one)?

image

@karthiknadig
Copy link
Member

@fabioz I can move it into the vscode repo, if this turns out to be a vscode issue.

@zljubisic
Copy link
Author

Reported problem has happened on my business computer. Now, I have created a new python project on my personal computer in which I have put what I usually put in my business projects (I know it is not the same but on my business computer I cannot provide a log file).

I cannot provoke an error with pandas dataframe, but if I print the same line several times, I get different line spacing. Please look at the picture. I am just pressing up arrow, than enter all the time. Output sometimes has a single blank line, sometimes more than one blank line.

image

When I experience the error on my business computer, while I am in debug console, how can I collect an environment, settings and everything else that I an compare with debug console environment, settings... on my personal computer?

@zljubisic
Copy link
Author

Also you can see that nothin is printed after I have passed over print(len(df)) line.

image

@zljubisic
Copy link
Author

Furthermore how come that pandas options:
pd.options.display.max_colwidth = None and
pd.options.display.expand_frame_repr = False

doesn't make any difference?
For example if I set max_colwidth to None, no matter how wide the colum is, it should be printed in the full width (you cannot see it, but I have a plenty of room to the right).
Option expand_frame_repr should prevent line breaking dataframe rows.

image

@fabioz
Copy link
Contributor

fabioz commented Oct 7, 2022

Furthermore how come that pandas options: pd.options.display.max_colwidth = None and pd.options.display.expand_frame_repr = False

doesn't make any difference? For example if I set max_colwidth to None, no matter how wide the colum is, it should be printed in the full width (you cannot see it, but I have a plenty of room to the right). Option expand_frame_repr should prevent line breaking dataframe rows.

If you set it to None then the limits set in through the PYDEVD_PANDAS_XXX environment variables become active (see: microsoft/debugpy#1078 (comment)).

@fabioz fabioz changed the title Last line in pandas dataframe is swallowed in (pytest) debug console The representation of a variable introspected in the debugger can be clipped on VSCode. Oct 7, 2022
@fabioz
Copy link
Contributor

fabioz commented Oct 7, 2022

@karthiknadig can you move this to VSCode?

I'm confident that the original issue (where the last line of pandas isn't visible) is because VSCode itself is clipping the content, so, it's not fixable in debugpy (also, from the description sometimes it's not clipped, but it has different heights even with the same content).

@zljubisic please refer to microsoft/debugpy#1078 (and keep the discussion to that issue) for customization of pandas as this issue should be moved to the VSCode repo to fix the layout issue in the Debug Console where the layout gets clipped sometimes (and other times it has different heights even with the same content).

@fabioz fabioz changed the title The representation of a variable introspected in the debugger can be clipped on VSCode. The representation of a variable introspected in the Debug Console can be clipped on VSCode. Oct 7, 2022
@karthiknadig karthiknadig transferred this issue from microsoft/debugpy Oct 7, 2022
@VSCodeTriageBot
Copy link
Collaborator

Thanks for creating this issue! It looks like you may be using an old version of VS Code, the latest stable release is 1.72.0. Please try upgrading to the latest version and checking whether this issue remains.

Happy Coding!

@roblourens
Copy link
Member

This issue may have been fixed in 1.72, please upgrade and let me know if you still see it

@roblourens roblourens added the info-needed Issue requires more information from poster label Oct 7, 2022
@zljubisic
Copy link
Author

I have upgraded to 1.72. Which test case you are interested in because I have created several of them.

@roblourens
Copy link
Member

All of these cases with the end of the message clipped or missing - I'm expecting that to be fixed.

@zljubisic
Copy link
Author

There is a problem with vertical space when printing the same thing several times.
Please note different vertical space between print command and header of dataframe("first"):

image

image

image

@zljubisic
Copy link
Author

Still you can't use pandas options:

image

@roblourens
Copy link
Member

That's a bit strange, I don't see that. Is there any chance that you are pressing enter multiple times while evaluating these statements? That will insert blank spaces.

Pandas options are still covered by the above statement #162965 (comment)

@zljubisic
Copy link
Author

There is no chance that I am pressing enter (on mechanical) keyboard more than once.
I can cause this behavior at will in let's say 5-6 retries.
I believe that this is one of reasons why pandas dataframe sometimes doesn't show the very last row.
I noticed problem with last row in big nested dictionaries as well.
Problem exists that is for sure.

@zljubisic
Copy link
Author

Do we have a plan with this issue?

@fabioz
Copy link
Contributor

fabioz commented Oct 28, 2022

@roblourens one thing to note is that in this use case he has disabled word-wrap in the debug console -- and in microsoft/debugpy#1078 (comment) there are some other strange things in his use case.

I've been able to reproduce getting different heights in this case (but I haven been able to reproduce the case where this makes a clip as in the report).

@roblourens roblourens added bug Issue identified by VS Code Team member as probable bug debug Debug viewlet, configurations, breakpoints, adapter issues debug-console and removed info-needed Issue requires more information from poster labels Dec 29, 2022
@roblourens roblourens added this to the Backlog milestone Dec 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug debug Debug viewlet, configurations, breakpoints, adapter issues debug-console
Projects
None yet
Development

No branches or pull requests

5 participants