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

.select event not passing EventData in multi-column Dataset #8639

Open
1 task done
dwipper opened this issue Jun 26, 2024 · 0 comments
Open
1 task done

.select event not passing EventData in multi-column Dataset #8639

dwipper opened this issue Jun 26, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@dwipper
Copy link

dwipper commented Jun 26, 2024

Describe the bug

As demonstrated in the below code, in a single column Dataset, when a row is selected, the .select event will pass the selected row/value. In the two-column Dataset, when a row is selected, it appears that nothing happens, i.e. the function isn't getting called (or is failing behind the scenes).

Have you searched existing issues? 🔎

  • I have searched and found no existing issues

Reproduction


def init_ds_two_col():
    ds = [['Text 1',"<img src='https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1u64v34tov7a3tdqitrz.png' width='100px' height='100px'>"],
          ['Text 2', "<img src='https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1u64v34tov7a3tdqitrz.png' width='100px' height='100px'>"],
          ['Text 3', "<img src='https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1u64v34tov7a3tdqitrz.png' width='100px' height='100px'>"],
          ['Text 4', "<img src='https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1u64v34tov7a3tdqitrz.png' width='100px' height='100px'>"],
          ['Text 5', "<img src='https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1u64v34tov7a3tdqitrz.png' width='100px' height='100px'>"]]
    return ds

def init_ds_one_col():
    ds = [['Text 1'],
          ['Text 1'],
          ['Text 1'],
          ['Text 1'],
          ['Text 1']]
    return ds

def get_selection(evt: gr.SelectData):
    print("Row Selected")
    print(evt.value)
    return

with gr.Blocks() as demo:
    one_col_ds = gr.Dataset(components=[gr.Textbox(visible=False)], headers=['Textbox'], label='One Column Test', samples=init_ds_one_col())
    one_col_ds.select(fn=get_selection, inputs=None, outputs=None)

    two_col_ds = gr.Dataset(components=[gr.Textbox(visible=False), gr.HTML(visible=False)], headers=['Textbox','Image'], label='Two Columns Test', samples=init_ds_two_col())
    two_col_ds.select(fn=get_selection, inputs=None, outputs=None)

if __name__ == "__main__":
    demo.launch()

Screenshot

No response

Logs

None

System Info

Gradio Environment Information:
------------------------------
Operating System: Darwin
gradio version: 4.29.0
gradio_client version: 0.16.1

------------------------------------------------
gradio dependencies in your environment:

aiofiles: 23.2.1
altair: 5.2.0
fastapi: 0.109.2
ffmpy: 0.3.1
gradio-client==0.16.1 is not installed.
httpx: 0.26.0
huggingface-hub: 0.20.3
importlib-resources: 6.1.1
jinja2: 3.1.3
markupsafe: 2.1.5
matplotlib: 3.8.2
numpy: 1.26.4
orjson: 3.9.13
packaging: 23.2
pandas: 2.2.1
pillow: 10.2.0
pydantic: 2.6.1
pydub: 0.25.1
python-multipart: 0.0.9
pyyaml: 6.0.1
ruff: 0.2.2
semantic-version: 2.10.0
tomlkit==0.12.0 is not installed.
typer: 0.12.3
typing-extensions: 4.9.0
urllib3: 2.2.0
uvicorn: 0.27.0.post1
authlib; extra == 'oauth' is not installed.
itsdangerous; extra == 'oauth' is not installed.


gradio_client dependencies in your environment:

fsspec: 2024.2.0
httpx: 0.26.0
huggingface-hub: 0.20.3
packaging: 23.2
typing-extensions: 4.9.0
websockets: 11.0.3

Severity

Blocking usage of gradio

@dwipper dwipper added the bug Something isn't working label Jun 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant