-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide status updates on file uploads #6307
Conversation
🪼 branch checks and previews
Install Gradio from this PR pip install https://gradio-builds.s3.amazonaws.com/5840b480bbd93504393af02878a52f709ab71d73/gradio-4.1.1-py3-none-any.whl Install Gradio Python Client from this PR pip install "gradio-client @ git+https://github.com/gradio-app/gradio@5840b480bbd93504393af02878a52f709ab71d73#subdirectory=client/python" |
🦄 change detectedThis Pull Request includes changes to the following packages.
With the following changelog entry.
Maintainers or the PR author can modify the PR title to modify this entry.
|
I think this is in good enough shape to get some thoughts from people! |
This is awesome @freddyaboulton! |
I do notice the flicker as well when I test it out -- my thinking is that this means we should change the UI a bit. One idea would be instead of a flicker that covers the whole component, a % that shows up in place of the file size while the file is being uploaded |
We had this problem with StatusTracker where quick functions had a flicker of showing the progress animation and then disappearing. I solved this by adding a transparency animation of 0.1s, so the progress bar quickly comes into view and leaves the view, but for very quick functions it basically never has time to transition into view at all. See here: gradio/js/statustracker/static/index.svelte Line 285 in 5a745ed
|
Another approach is to set a threshold, or 0.2s or so. If something takes less than the threshold, do nothing, otherwise show the animation. |
if it ends up taking 0.21 seconds, you'd still get a flicker though right? |
Yah you would (although you could also animate it). But the same is kinda true with an animation, you can still get flashes if the timing is wrong, they are just a little gentler. I don't think there is a great way to solve it though. There are APIs (in chrome) to check for networks speed / datasaving mode, but they aren't super informative. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good to me!
I was thinking about the design of the progress update requests being called directly from UploadProgress.svelte. In my mind, it would have been cleaner if the client handled tracking the upload progress (bc it's the client's responsibility to handle communication with the backend) and the client.upload method can take a callback function that it calls with upload progress updates. Don't feel too strongly about it though.
0cd3483
to
74da326
Compare
Thanks for the reviews all! Implemented the opacity transition to reduce flicker. Going to merge but @hannahblair is going to open a PR to improve the progress bar styling later this week! |
Perhaps we should have avoided merging this in until the UI was ready as it blocks doing a release from |
Yeah. We should always keep main releasable (it also muddies the change log). |
Description
Closes #6218
/upload
route. When specified, you can listen to progress updates on theupload_progress
route. I originally wanted the/upload
route to return theupload_id
you can use to listen to updates but we can't send intermediate information from the/upload
route without closing the request and the/upload
route needs the request to stay open to stream the files.UploadProgress.svelte
class in@gradio/upload
that streams and displays progress updates from the server.upload_id
parameter is added to the@gradio/client
but not the python client.Try it here: https://huggingface.co/spaces/freddyaboulton/file_component
Questions:
🎯 PRs Should Target Issues
Before your create a PR, please check to see if there is an existing issue for this change. If not, please create an issue before you create this PR, unless the fix is very small.
Not adhering to this guideline will result in the PR being closed.
Tests
PRs will only be merged if tests pass on CI. To run the tests locally, please set up your Gradio environment locally and run the tests:
bash scripts/run_all_tests.sh
You may need to run the linters:
bash scripts/format_backend.sh
andbash scripts/format_frontend.sh