gradio
gradio copied to clipboard
Bug on dataset updated
Discussed in https://github.com/gradio-app/gradio/discussions/2136
Originally posted by ledadu August 31, 2022 Hi. When i update the dataset , the componant is updated. But, when i click on new a element of the datset bbb => the last value 'aaa' is returned !
import gradio as gr
def update_dataset():
# Here I want to implement the picture library refresh function
return gr.Dataset.update(samples=[['bbb'],['cccc']])
def dataset_click(data):
print('dataset_click', data)
return data[0]
with gr.Blocks() as demo:
with gr.Row():
with gr.Column():
with gr.Row():
btn = gr.Button(value="Reset dataset")
with gr.Row():
input_text = gr.Textbox(label="text from exemple")
with gr.Row():
example_text_list = gr.Dataset(components=[input_text], samples=[['aaa']])
btn.click(fn=update_dataset, inputs=[], outputs=[example_text_list])
example_text_list.click(fn=dataset_click, inputs=[example_text_list], outputs=[input_text])
demo.launch(debug=True)
Hi @ledadu thanks for bringing this to our attention. This is related to another issue: #1566. It's a bit of complex problem actually but we'll look into this
Closing as this is a special case of #1566