Skip to content

Commit

Permalink
feat: exception handling about file_count params of File component (#…
Browse files Browse the repository at this point in the history
…8529)

* feat: exception handling about file_count params of File component

* lint

* add changeset

---------

Co-authored-by: zedd.ai <zedd.ai@kakaomobility.com>
Co-authored-by: freddyaboulton <alfonsoboulton@gmail.com>
Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
  • Loading branch information
4 people authored Jun 11, 2024
1 parent 7c5fec3 commit d43d696
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/tangy-moose-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"gradio": minor
---

feat:feat: exception handling about file_count params of File component
8 changes: 7 additions & 1 deletion gradio/components/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,14 @@ def __init__(
render: If False, component will not render be rendered in the Blocks context. Should be used if the intention is to assign event listeners now but render the component later.
key: if assigned, will be used to assume identity across a re-render. Components that have the same key across a re-render will have their value preserved.
"""
file_count_valid_types = ["single", "multiple", "directory"]
self.file_count = file_count
if self.file_count in ["multiple", "directory"]:

if self.file_count not in file_count_valid_types:
raise ValueError(
f"Parameter file_count must be one of them: {file_count_valid_types}"
)
elif self.file_count in ["multiple", "directory"]:
self.data_model = ListFiles
else:
self.data_model = FileData
Expand Down

0 comments on commit d43d696

Please sign in to comment.