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

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

Open
danhje opened this issue Sep 17, 2024 · 2 comments
Open

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

danhje opened this issue Sep 17, 2024 · 2 comments
Labels
external Issue belongs to another repository

Comments

@danhje
Copy link

danhje commented Sep 17, 2024

Environment data

  • VS Code version: 1.93.1
  • Data Wrangler Extension version (available under the Extensions sidebar): v1.8.1
  • Jupyter Extension version (available under the Extensions sidebar): v2024.8.1
  • Python Extension version (available under the Extensions sidebar): v2024.14.1
  • OS (Windows | Mac | Linux distro) and version: Windows 11
  • Pandas version: 2.2.2
  • Python and/or Anaconda version: 3.12.5
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): poetry venv

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
Copy link
Member

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>)

@kopytjuk
Copy link

kopytjuk commented Nov 8, 2024

The same problem can be observed with StrEnum keys:

from enum import Enum, StrEnum

import numpy as np
import pandas as pd


class StringEnum(StrEnum):
    A = "foo"
    B = "bar"


class NormalEnum(Enum):
    A = 1
    B = 2


container = {
    # error message "Could not retrieve variable container[<StringEnum.A: 'foo'>] from the Jupyter extension. Please file an issue on the Data Wrangler GitHub repository."
    StringEnum.A: pd.DataFrame(data=np.arange(4).reshape((2, 2)), columns=["A", "B"]),
    # "View Value in Data Wrangler" does not  show up in the context menu in debugger
    NormalEnum.A: pd.DataFrame(data=np.arange(4).reshape((2, 2)), columns=["A", "B"]),
    # OK
    "works": pd.DataFrame(data=np.arange(4).reshape((2, 2)), columns=["A", "B"]),
    # OK
    1: pd.DataFrame(data=np.arange(4).reshape((2, 2)), columns=["A", "B"])
}

pass

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
external Issue belongs to another repository
Projects
None yet
Development

No branches or pull requests

3 participants