microsoft / vscode-data-wrangler

Other
425 stars 18 forks source link

DW fails to display DataFrame in dict where key is Enum member #285

Open danhje opened 1 week ago

danhje commented 1 week ago

Environment data

Expected behaviour

DataFrame is displayed

Actual behaviour

Nothing happens

Steps to reproduce:

Debug this script with a breakpoint on pass:

from enum import Enum
import pandas as pd

class MyEnum(Enum):
    ONE = 1

df = pd.DataFrame({'a': [1, 2, 3], 'b': [4, 5, 6]})
d = {"ONE": df, MyEnum.ONE: df}

pass

The DF that corresponds to the "ONE" key opens without issue, but the DF that corresponds with the MyEnum.ONE value does not.

pwang347 commented 1 week ago

Hi @danhje, thank you for reporting the issue! It looks like this one is also a problem with the Jupyter extension's variable delegation.

From Jupyter output logs (with logging level set to debug):

image

Working launch:

11:46:41.719 [debug] Evaluating in debugger : 60f5e28b-9a31-4f3b-b97d-e1c5c98594d1: _VSCODE_getVariable("info", True, d['ONE'])
11:46:41.771 [info] Showing data viewer with command dataWrangler.launchDataViewer for variable {"name":"d['ONE']","type":"DataFrame","count":3,"shape":"(3, 2)","size":0,"supportsDataExplorer":false,"value":"...","truncated":false,"frameId":8,"fullType":"pandas.core.frame.DataFrame"}

Failing launch (doesn't show launch message):

11:46:52.371 [debug] Evaluating in debugger : 60f5e28b-9a31-4f3b-b97d-e1c5c98594d1: _VSCODE_getVariable("info", True, <MyEnum.ONE: 1>)