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

datatype="markdown" of gr.Dataframe is applied only up to the third column #6066

Closed
1 task done
hysts opened this issue Oct 23, 2023 · 5 comments · Fixed by #7286
Closed
1 task done

datatype="markdown" of gr.Dataframe is applied only up to the third column #6066

hysts opened this issue Oct 23, 2023 · 5 comments · Fixed by #7286
Labels
bug Something isn't working good first issue Good for newcomers Priority High priority issues python Backend-related issue (Python)

Comments

@hysts
Copy link
Collaborator

hysts commented Oct 23, 2023

Describe the bug

When setting datatype of gr.Dataframe with str, e.g. datatype="markdown", it seems to be applied to only the first three columns, and the rest seems to be set to str.
(One can work around this by setting it with list[str], like datatype=["markdown"] * 5, though.)

Have you searched existing issues? 🔎

  • I have searched and found no existing issues

Reproduction

https://huggingface.co/spaces/hysts-debug/dataframe-datatype

import gradio as gr
import pandas as pd

x = ["[Hugging Face](https://huggingface.co/)", "[Gradio](https://www.gradio.app/)"]
df = pd.DataFrame(data={f"{i}": x for i in range(5)})

with gr.Blocks() as demo:
    gr.Dataframe(value=df, datatype="markdown")

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

Screenshot

Logs

No response

System Info

Gradio Environment Information:
------------------------------
Operating System: Linux
gradio version: 3.50.2
gradio_client version: 0.6.1

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

aiofiles: 23.2.1
altair: 5.1.2
fastapi: 0.104.0
ffmpy: 0.3.1
gradio-client==0.6.1 is not installed.
httpx: 0.25.0
huggingface-hub: 0.18.0
importlib-resources: 6.1.0
jinja2: 3.1.2
markupsafe: 2.1.3
matplotlib: 3.8.0
numpy: 1.26.1
orjson: 3.9.9
packaging: 23.2
pandas: 2.1.1
pillow: 10.1.0
pydantic: 1.10.13
pydub: 0.25.1
python-multipart: 0.0.6
pyyaml: 6.0.1
requests: 2.31.0
semantic-version: 2.10.0
typing-extensions: 4.8.0
uvicorn: 0.23.2
websockets: 11.0.3
authlib; extra == 'oauth' is not installed.
itsdangerous; extra == 'oauth' is not installed.


gradio_client dependencies in your environment:

fsspec: 2023.6.0
httpx: 0.25.0
huggingface-hub: 0.18.0
packaging: 23.2
requests: 2.31.0
typing-extensions: 4.8.0
websockets: 11.0.3

Severity

I can work around it

@hysts hysts added the bug Something isn't working label Oct 23, 2023
@hysts
Copy link
Collaborator Author

hysts commented Nov 1, 2023

This issue remains in gradio==4.0.2.

@fakerybakery
Copy link

+1, noticing this as well

@pngwn
Copy link
Member

pngwn commented Jan 22, 2024

Weird that is it 3. Could be related to the default data being 3 columns? Might just be the frontend not reacting to changes.

@fakerybakery
Copy link

My code has >3 columns from the start, still noticing the problem, see #7052

@pngwn
Copy link
Member

pngwn commented Jan 22, 2024

Just checked, its this: https://github.com/gradio-app/gradio/blob/main/gradio/components/dataframe.py#L113-L115

The backend converts the single value into a list based on the current col_count on initialisation, but that doesn't necessarily mean there will only be that many columns. It also won't update if the table is updated to another set of dimensions, or even if the col count is explicitly changed in a user fn.

The frontend already has logic to handle a single value being passed or a list of values, so the backend should just leave this as it is. The logic linked above should just be removed and the param value set and the instance value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers Priority High priority issues python Backend-related issue (Python)
Projects
None yet
4 participants