gradio
gradio copied to clipboard
Progress doesn't work with * arguments
Describe the bug
When the gradio app becomes really big, it's very convenient to accept all args through *args syntax. But in this case the progress bar doesn't show up. Below is slightly modified version from docs which doesn't work.
import time
import gradio as gr
def reverse(word, *args, progress=gr.Progress()):
print(args)
progress(0, desc="Starting")
time.sleep(1)
new_string = ""
for idx, letter in enumerate(word):
time.sleep(0.25)
new_string = letter + new_string
progress(1 / len(word) * (idx + 1), desc="Reversing")
return new_string
demo = gr.Interface(reverse, [gr.Text(), gr.Number(), gr.Number()], gr.Text())
demo.queue().launch()
re-arranging inputs to be: def reverse(word, progress=gr.Progress(), *args): solves the problem, but is not very obvious. Maybe just adding this fact to the docs would help.
Have you searched existing issues? 🔎
- [X] I have searched and found no existing issues
Reproduction
see above
Screenshot
No response
Logs
No response
System Info
❯ pip show gradio
Name: gradio
Version: 3.36.1
Severity
I can work around it