gradio
gradio copied to clipboard
update gr.Dataset gets AttributeError: 'Textbox' object has no attribute 'proxy_url'
Describe the bug
I tried to update samples of the Dataset component and it failed with the following error:
Traceback (most recent call last):
File "/data1/conda/agents/lib/python3.9/site-packages/gradio/queueing.py", line 427, in call_prediction
output = await route_utils.call_process_api(
File "/data1/conda/agents/lib/python3.9/site-packages/gradio/route_utils.py", line 232, in call_process_api
output = await app.get_blocks().process_api(
File "/data1/conda/agents/lib/python3.9/site-packages/gradio/blocks.py", line 1525, in process_api
result = await self.call_function(
File "/data1/conda/agents/lib/python3.9/site-packages/gradio/blocks.py", line 1147, in call_function
prediction = await anyio.to_thread.run_sync(
File "/data1/conda/agents/lib/python3.9/site-packages/anyio/to_thread.py", line 33, in run_sync
return await get_asynclib().run_sync_in_worker_thread(
File "/data1/conda/agents/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 877, in run_sync_in_worker_thread
return await future
File "/data1/conda/agents/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 807, in run
result = context.run(func, *args)
File "/data1/conda/agents/lib/python3.9/site-packages/gradio/utils.py", line 672, in wrapper
response = f(*args, **kwargs)
File "/data/codes/test/langchain/server/gradio_test.py", line 21, in change_dataset
return gr.Dataset(components=["textbox"], visible=False)
File "/data1/conda/agents/lib/python3.9/site-packages/gradio/component_meta.py", line 152, in wrapper
return fn(self, **kwargs)
File "/data1/conda/agents/lib/python3.9/site-packages/gradio/components/dataset.py", line 73, in __init__
self.component_props = [
File "/data1/conda/agents/lib/python3.9/site-packages/gradio/components/dataset.py", line 75, in <listcomp>
component.get_config(),
File "/data1/conda/agents/lib/python3.9/site-packages/gradio/components/base.py", line 212, in get_config
config = super().get_config()
File "/data1/conda/agents/lib/python3.9/site-packages/gradio/blocks.py", line 216, in get_config
config = {**config, "proxy_url": self.proxy_url, "name": self.get_block_name()}
AttributeError: 'Textbox' object has no attribute 'proxy_url'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/data1/conda/agents/lib/python3.9/site-packages/gradio/queueing.py", line 472, in process_events
response = await self.call_prediction(awake_events, batch)
File "/data1/conda/agents/lib/python3.9/site-packages/gradio/queueing.py", line 436, in call_prediction
raise Exception(str(error) if show_error else None) from error
Exception: 'Textbox' object has no attribute 'proxy_url'
Have you searched existing issues? 🔎
- [X] I have searched and found no existing issues
Reproduction
I used this code modified from the Updating Component Configurations example to reproduce.
import gradio as gr
def change_dataset(choice):
if choice == "short":
return gr.Dataset(components=["textbox"], samples=[["1", "2"]])
elif choice == "long":
return gr.Dataset(components=["textbox"], samples=[["1", "2", "3", "4", "5", "6", "7", "8"]])
else:
return gr.Dataset(components=["textbox"], visible=False)
with gr.Blocks() as demo:
radio = gr.Radio(
["short", "long", "none"], label="What kind of essay would you like to write?"
)
dataset = gr.Dataset(label="essay", components=["textbox"], samples=[[""]], samples_per_page=15)
radio.change(fn=change_dataset, inputs=radio, outputs=dataset)
demo.launch()
Screenshot
No response
Logs
No response
System Info
Gradio Environment Information:
------------------------------
Operating System: Linux
gradio version: 4.3.0
gradio_client version: 0.7.0
------------------------------------------------
gradio dependencies in your environment:
aiofiles: 23.2.1
altair: 5.0.1
fastapi: 0.101.1
ffmpy: 0.3.1
gradio-client==0.7.0 is not installed.
httpx: 0.24.1
huggingface-hub: 0.16.4
importlib-resources: 6.1.0
jinja2: 3.1.2
markupsafe: 2.1.3
matplotlib: 3.3.4
numpy: 1.19.5
orjson: 3.9.5
packaging: 23.0
pandas: 1.1.5
pillow: 8.4.0
pydantic: 2.4.2
pydub: 0.25.1
python-multipart: 0.0.6
pyyaml: 6.0.1
requests: 2.26.0
semantic-version: 2.10.0
tomlkit==0.12.0 is not installed.
typer: 0.9.0
typing-extensions: 4.7.1
uvicorn: 0.23.2
authlib; extra == 'oauth' is not installed.
itsdangerous; extra == 'oauth' is not installed.
gradio_client dependencies in your environment:
fsspec: 2023.6.0
httpx: 0.24.1
huggingface-hub: 0.16.4
packaging: 23.0
requests: 2.26.0
typing-extensions: 4.7.1
websockets: 11.0.3
Severity
Blocking usage of gradio
I faced same issue.
try return gr.update(components=["textbox"], visible=False)
instead of return gr.Dataset(components=["textbox"], visible=False)
Same issue. jaywican's proposed fix doesn't work.
Same issue here. I tried something even more simple without luck. If you just take as input a Dataset and return it as is, this still doesn't work.
In gradio 4.13.0, I didn't put gr.Dataset() in the return value and just returned the sample value I wanted to replace, and it worked fine.
def change_dataset(choice):
if choice == "short":
return [["1", "2"]]
elif choice == "long":
return [["1", "2", "3", "4", "5", "6", "7", "8"]]
else:
return gr.update(visible=False)
I am using Dataset as Dataframe, and one of the column is path to an Audio file. Using following code I instantiate the component:
examples_table = gr.Dataset(
components=[gr.TextArea(visible=False), gr.Number(visible=False), gr.Number(visible=False), gr.Number(visible=False), gr.Number(visible=False), gr.Audio(visible=False)],
headers=["Text", "Temperature", "Length Scale", "Steps", "Execution Time", "Audio Path"],
)
audio_output = gr.Audio()
On using @jaywican code, I append new values to a global variable and send it during an event trigger. Instead of Audio Widget, the column contains just the text, which is the path of the audio file. How to render the Audio widget, using following code.
example_df = []
def event_on_button_click(text, temperature, length_scale, steps):
global example_df
audio_path, total_execution_time = synthesise(text, temperature, length_scale, steps)
example_df.append([text, temperature, length_scale, steps, total_execution_time, audio_path])
return example_df, audio_path
but2 = gr.Button(label="Synthesise")
but2.click(
fn=event_on_button_click,
inputs=[text, temperature_slider, length_scale_slider, steps_slider],
outputs=[audio_output, examples_table]
)
How to render the Audio widget in the Dataset component?