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
Fix the download button of the gr.Gallery()
component to work
#6487
Conversation
🪼 branch checks and previews
Install Gradio from this PR pip install https://gradio-builds.s3.amazonaws.com/58456569f2c99c23c99cc5121cecfea11d514927/gradio-4.8.0-py3-none-any.whl Install Gradio Python Client from this PR pip install "gradio-client @ git+https://github.com/gradio-app/gradio@58456569f2c99c23c99cc5121cecfea11d514927#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.
|
cd257c2
to
87e4b23
Compare
js/gallery/shared/Gallery.svelte
Outdated
if (selected_image == null) { | ||
return; | ||
} | ||
const { url, orig_name } = selected_image; |
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.
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.
That's a good fix @whitphx - thanks
8193a85
to
779aa2c
Compare
Hey @whitphx! Ignore the above - I needed to rebuild the FE. So I'm still experiencing some weird behaviour when running the gallery component demo. See this recording: To summarise the above: The first image downloaded the image as a .jpg, as expected. |
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.
Thanks for the fix! Do you mind modifying the 2e2 test (gallery_component_events.spec.ts
) to download a file from the gallery and make sure it has the right name?
The video tests show how to download files with playwright, should be something like
const downloadPromise = page.waitForEvent("download");
await page.getByLabel("Download").click();
const download = await downloadPromise;
await expect(download.suggestedFilename()).toBe(<name>);
e340c1f
to
e96d7dd
Compare
@hannahblair @freddyaboulton Thank you for the review! I modified the code
Then the CORS problem should be solved and updating the E2E test became unnecessary. |
378f930
to
dcac42b
Compare
9acc972
to
f8fb748
Compare
gradio/components/gallery.py
Outdated
else: | ||
raise ValueError(f"Cannot process type as image: {type(img)}") | ||
entry = GalleryImage( | ||
image=FileData(path=file_path, url=url), caption=caption | ||
# Leave `url` as None so it will be replaced with a local cache path during postprocessing (https://github.com/gradio-app/gradio/blob/c5ea13bdf7363224863760e53fbcdbed81754628/gradio/blocks.py#L1421) |
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.
This will introduce a regression in performance when compared to main.
You can check with the gallery_component_events
demo. The postprocess will take several seconds as opposed to < 1 second.
This change
Main
In the past, people have used gr.Gallery to store many image URLs so I'm worried about degrading the experience for them.
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.
That's an important point, thanks.
I understand gr.Gallery()
is not just a group of gr.Images()
but the quantity matters.
So I'm gonna go back to the previous path and improve it.
849802f
to
f50238c
Compare
e718b95
to
d403fab
Compare
1ecac84
to
93a173d
Compare
4ab12bb
to
6e556c3
Compare
Awesome PR, thanks for this nice bug fix @whitphx! Left a couple of very minor points above |
The suggested type syntax didn't work. Ref: |
The failed test is only the flaky one. Will merge this ignoring it. |
Description
Fix the bug of the download button on
gr.Gallery()
.Closes: #6486