gradio-app / gradio

Build and share delightful machine learning apps, all in Python. 🌟 Star to support our work!
http://www.gradio.app
Apache License 2.0
33.28k stars 2.51k forks source link

Dataframe cell never gets unselected when there are multiple dataframes. #9566

Open yoonniverse opened 1 week ago

yoonniverse commented 1 week ago

Describe the bug

When there are multiple dataframes, selected cells of the dataframes except first one never gets unselected. The cell is selected forever until the user refreshes the browser, so it results in unexpected behaviors with event triggers.

Have you searched existing issues? 🔎

Reproduction

import time
import pandas as pd
import gradio as gr

with gr.Blocks() as blocks:

    def update_first_df(df):
        print('update first df')
        time.sleep(1)
        return df + 1

    def update_second_df(df):
        print('update second df')
        time.sleep(1)
        return df + 1

    first_df = gr.Dataframe(pd.DataFrame({'A': [1], 'B': [2]}))
    second_df = gr.Dataframe(pd.DataFrame({'A': [3], 'B': [4]}))

    first_df.select(fn=update_second_df, inputs=[second_df], outputs=[second_df])
    second_df.select(fn=update_first_df, inputs=[first_df], outputs=[first_df])

blocks.launch()

Select second df cell, then first df cell. Both of the cells will be in selected state, and due to https://github.com/gradio-app/gradio/issues/9568, the update will go forever. If this is the expected behavior, it would be nice to have click event on the dataframe cell.

Screenshot

image

Logs

No response

System Info

Gradio Environment Information:
------------------------------
Operating System: Windows
gradio version: 4.44.1
gradio_client version: 1.3.0

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

aiofiles: 23.2.1
anyio: 4.4.0
fastapi: 0.115.0
ffmpy: 0.4.0
gradio-client==1.3.0 is not installed.
httpx: 0.27.2
huggingface-hub: 0.24.6
importlib-resources: 6.4.5
jinja2: 3.1.3
markupsafe: 2.1.5
matplotlib: 3.9.2
numpy: 2.0.2
orjson: 3.10.7
packaging: 24.1
pandas: 2.2.2
pillow: 10.4.0
pydantic: 2.8.2
pydub: 0.25.1
python-multipart: 0.0.9
pyyaml: 6.0.2
ruff: 0.6.5
semantic-version: 2.10.0
tomlkit==0.12.0 is not installed.
typer: 0.12.5
typing-extensions: 4.12.2
urllib3: 2.2.2
uvicorn: 0.23.2
authlib; extra == 'oauth' is not installed.
itsdangerous; extra == 'oauth' is not installed.

gradio_client dependencies in your environment:

fsspec: 2024.6.1
httpx: 0.27.2
huggingface-hub: 0.24.6
packaging: 24.1
typing-extensions: 4.12.2
websockets: 12.0

Severity

Blocking usage of gradio

CISC commented 1 week ago

I can confirm this bug (which meant I had to disable Dataframe selection in GGUF Editor), but couldn't reproduce it (since it didn't occur to me that the issue was multiple Dataframes), thankfully I only really need one Dataframe, so I managed to work around it once I saw this issue, thank you! :)