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

Check file_types is a list #3048

Merged
merged 4 commits into from
Jan 25, 2023
Merged

Check file_types is a list #3048

merged 4 commits into from
Jan 25, 2023

Conversation

freddyaboulton
Copy link
Collaborator

Description

Fixes #3043

As noted in #3043, if file_types is not a list, the app will crash. Raising an error on the back-end to check that parameter is a list!

Checklist:

  • I have performed a self-review of my own code
  • I have added a short summary of my change to the CHANGELOG.md
  • My code follows the style guidelines of this project
  • I have commented my code in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

A note about the CHANGELOG

Hello 👋 and thank you for contributing to Gradio!

All pull requests must update the change log located in CHANGELOG.md, unless the pull request is labeled with the "no-changelog-update" label.

Please add a brief summary of the change to the Upcoming Release > Full Changelog section of the CHANGELOG.md file and include
a link to the PR (formatted in markdown) and a link to your github profile (if you like). For example, "* Added a cool new feature by [@myusername](link-to-your-github-profile) in [PR 11111](https://github.com/gradio-app/gradio/pull/11111)".

If you would like to elaborate on your change further, feel free to include a longer explanation in the other sections.
If you would like an image/gif/video showcasing your feature, it may be best to edit the CHANGELOG file using the
GitHub web UI since that lets you upload files directly via drag-and-drop.

@gradio-pr-bot
Copy link
Collaborator

All the demos for this PR have been deployed at https://huggingface.co/spaces/gradio-pr-deploys/pr-3048-all-demos

@freddyaboulton freddyaboulton marked this pull request as ready for review January 24, 2023 14:24
@@ -2250,6 +2250,10 @@ def __init__(
"""
self.file_count = file_count
self.file_types = file_types
if file_types is not None and not isinstance(file_types, list):
raise ValueError(
f"Parameter file_types must be a list. Received {file_types.__class__.__name__}"
Copy link
Member

@abidlabs abidlabs Jan 24, 2023

Choose a reason for hiding this comment

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

Did not know you could do .__class__ on primitives, nice!

@abidlabs
Copy link
Member

Thanks @freddyaboulton, this looks good! Can you also add this logic to gr.UploadButton()?

@freddyaboulton
Copy link
Collaborator Author

@abidlabs - good point! Just added that logic to UploadButton!

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.

Thanks @freddyaboulton LGTM!

@freddyaboulton
Copy link
Collaborator Author

Thank you for the review @abidlabs !

@freddyaboulton freddyaboulton merged commit 18cc8a3 into main Jan 25, 2023
@freddyaboulton freddyaboulton deleted the 3043-file-types-check branch January 25, 2023 09:32
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 with file_types="image" breaks front-end rendering
3 participants