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.91k stars 2.57k forks source link

Gradio `File` component doesn't display uploading progress bar #9514

Open BronzeCrab opened 1 month ago

BronzeCrab commented 1 month ago

Describe the bug

Gradio File component doesn't display progress bar in some cases. Gradio is making 2 requests to it's backend, when gr.File upload is started - one POST to the /upload endpont and one GET to the /upload_progress endpoint.

So, POST /upload endpont calls track method of FileUploadProgress instance and populating self._statuses dict of FileUploadProgress instance with upload_id of the file, and GET /upload_progress endpont basically returns stream of events of file with upload_id (uploading progress of this file).

OK.

But:

If GET to /upload_progress is executed FIRST (before the POST to the /upload), then this GET request will fail with FileUploadProgressNotTrackedError error, because there is no such upload_id in self._statuses dict of FileUploadProgress instance yet. And in this case, there will be no progress bar of uploading the file on frontend.

Have you searched existing issues? 🔎

Reproduction

This bug is reproduced sometimes, but sometimes there is no bug, it depends on the order of execution of GET and POST requests mentioned above. So, just try to ulpload different files several times:

import gradio as gr

with gr.Blocks() as demo:
    file_input = gr.File(
        label="test",
    )

demo.launch()

Screenshot

No response

Logs

No response

System Info

windows 11

gradio==4.44.1

Severity

I can't work with gradio File component properly.

Joodith commented 1 month ago

I would like to take a look into this issue and work on it.