Skip to content
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

Few File component drag and drop #7141

Merged
merged 12 commits into from
Jan 31, 2024
Merged

Few File component drag and drop #7141

merged 12 commits into from
Jan 31, 2024

Conversation

dawoodkhan82
Copy link
Collaborator

@dawoodkhan82 dawoodkhan82 commented Jan 24, 2024

Description

  • Fixes Drag and Drop for types of the first element in file_types
  • Added playwright playwright tests for drag & drop

Closes: #7094

🎯 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

  1. 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

  2. You may need to run the linters: bash scripts/format_backend.sh and bash scripts/format_frontend.sh

@gradio-pr-bot
Copy link
Collaborator

gradio-pr-bot commented Jan 24, 2024

🪼 branch checks and previews

Name Status URL
Spaces ready! Spaces preview
Website ready! Website preview
Storybook ready! Storybook preview
Visual tests all good! Build review
🦄 Changes detected! Details
📓 Notebooks matching!

Install Gradio from this PR

pip install https://gradio-builds.s3.amazonaws.com/7d24b83282c0203e79067fee47e77f5af7ba00b8/gradio-4.16.0-py3-none-any.whl

Install Gradio Python Client from this PR

pip install "gradio-client @ git+https://github.com/gradio-app/gradio@7d24b83282c0203e79067fee47e77f5af7ba00b8#subdirectory=client/python"

@gradio-pr-bot
Copy link
Collaborator

gradio-pr-bot commented Jan 24, 2024

🦄 change detected

This Pull Request includes changes to the following packages.

Package Version
@gradio/upload patch
gradio patch
  • Maintainers can select this checkbox to manually select packages to update.

With the following changelog entry.

Few File component drag and drop

Maintainers or the PR author can modify the PR title to modify this entry.

Something isn't right?

  • Maintainers can change the version label to modify the version bump.
  • If the bot has failed to detect any changes, or if this pull request needs to update multiple packages to different versions or requires a more comprehensive changelog entry, maintainers can update the changelog file directly.

@dawoodkhan82 dawoodkhan82 marked this pull request as draft January 24, 2024 20:00
@dawoodkhan82 dawoodkhan82 marked this pull request as ready for review January 31, 2024 17:24
@abidlabs
Copy link
Member

@dawoodkhan82 #7132 is already fixed, so I've removed it from the parent comment, and I think we can reduce some of the changes in this PR as a result

@dawoodkhan82 dawoodkhan82 changed the title Few File component fixes Few File component drag and drop Jan 31, 2024
@abidlabs
Copy link
Member

Thanks @dawoodkhan82. I tested this and can confirm that the original issue is fixed. However, the drag-and-drop doesn't seem to work with file extensions. Here's the repro:

import gradio as gr
def generate_file(file_obj):
    return None

inputs = gr.components.File( file_types = [ '.jpg', '.mov' ] )
outputs = gr.components.File()
demo = gr.Interface(fn=generate_file, inputs=inputs, outputs=outputs)
demo.launch()

If you try dragging-and-dropping .jpg or .mov files, they won't get uploaded (however, if you click on the file component, they'll still work)

@dawoodkhan82
Copy link
Collaborator Author

dawoodkhan82 commented Jan 31, 2024

@abidlabs Should be fixed now

@abidlabs
Copy link
Member

Extensions work but hmm now the original repro isn't working for me:

import gradio as gr
def generate_file(file_obj):
    return None

inputs = gr.components.File( file_types = [ 'image', 'video' ] )
outputs = gr.components.File()
demo = gr.Interface(fn=generate_file, inputs=inputs, outputs=outputs)
demo.launch()

@dawoodkhan82
Copy link
Collaborator Author

@abidlabs Ah yes I see what's going wrong. Need to pass both the file extension and file type of the uploaded file. Pushing a fix now.

@dawoodkhan82
Copy link
Collaborator Author

@abidlabs Can you double check and make sure it works for you now?

@dawoodkhan82 dawoodkhan82 requested a review from abidlabs January 31, 2024 20:27
Copy link
Member

@abidlabs abidlabs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Works for me now @dawoodkhan82 thanks

@dawoodkhan82 dawoodkhan82 merged commit c3e61e4 into main Jan 31, 2024
22 checks passed
@dawoodkhan82 dawoodkhan82 deleted the file-fixes branch January 31, 2024 21:23
@pngwn pngwn mentioned this pull request Jan 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

gr.File only supports Drag and Drop for types of the first element in file_types
3 participants