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

gr.Dropdown.update unable to render updated choices #5519

Closed RajarshiBhadra closed 1 year ago

RajarshiBhadra commented 1 year ago

Describe the bug

The dropdown update is returning corrupted values if triggered via change/click/submit

Have you searched existing issues? πŸ”Ž

Reproduction

import gradio as gr

def update_dropdown():
  new_choices = gr.Dropdown.update(choices = ["Hyundai","Suzuki","Mclaren"],label = "Test Dropdown")
  return new_choices

def update_text(text):
  return "You have chosen: " + text

with gr.Blocks() as demo:
  with gr.Row():
    with gr.Column():
      test = gr.Dropdown(choices = ["Honda","BMW","Mercedes"], value = "Honda",label = "Test Dropdown")
      output = gr.Textbox(lines = 5, label="Details")
    with gr.Column():
      test_button = gr.Button(value = "Test",variant = "primary" )
    test.change(update_text,[test],output)
    test_button.click(update_dropdown,[] ,[test])

demo.launch(debug = True)

Screenshot

Gradio Issue

Logs

No error

System Info

Gradio Environment Information:
------------------------------
Operating System: Linux
gradio version: 3.44.0
gradio_client version: 0.5.0

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

aiofiles: 23.2.1
altair: 4.2.2
fastapi: 0.103.1
ffmpy: 0.3.1
gradio-client==0.5.0 is not installed.
httpx: 0.25.0
huggingface-hub: 0.17.1
importlib-resources: 6.0.1
jinja2: 3.1.2
markupsafe: 2.1.3
matplotlib: 3.7.1
numpy: 1.23.5
orjson: 3.9.7
packaging: 23.1
pandas: 1.5.3
pillow: 9.4.0
pydantic: 1.10.12
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.5.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.17.1
packaging: 23.1
requests: 2.31.0
typing-extensions: 4.5.0
websockets: 11.0.3

Severity

Blocking usage of gradio

Valdanitooooo commented 1 year ago

same here

CUexter commented 1 year ago

same here. It only renders the first letter

abidlabs commented 1 year ago

Taking a look!

leemengtw commented 1 year ago

Same here. It only renders the first letter. Took me hours debugging and with no success solving this.

I'm using

gr.Dropdown.update(
    value='some value',
    choices=choices,
)

where choices are a list of strings like this:

image

But only the first character of each choice are rendered:

image

version:

gradio==3.44.0
gradio_client==0.5.0
RajarshiBhadra commented 1 year ago

@leemengtw there is a fix now. Check this link