Add orig_name field to video outputs (#3700)

* Add orig_name to video

* Fix test

* CHANGELOG

* Lint
This commit is contained in:
Freddy Boulton 2023-03-29 20:34:04 -04:00 committed by GitHub
parent 1229f3b001
commit f97b5c0c72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 2 deletions

View File

@ -58,7 +58,7 @@ No changes to highlight.
- Copy everything in website Dockerfile, fix build issues by [@aliabd](https://github.com/aliabd) in [PR 3659](https://github.com/gradio-app/gradio/pull/3659)
- Raise error when an event is queued but the queue is not configured by [@freddyaboulton](https://github.com/freddyaboulton) in [PR 3640](https://github.com/gradio-app/gradio/pull/3640)
- Allows users to apss in a string name for a built-in theme, by [@abidlabs](https://github.com/abidlabs) in [PR 3641](https://github.com/gradio-app/gradio/pull/3641)
- Added `orig_name` to Video output in the backend so that the front end can set the right name for downloaded video files by [@freddyaboulton](https://github.com/freddyaboulton) in [PR 3700](https://github.com/gradio-app/gradio/pull/3700)
## Contributors Shoutout:

View File

@ -2138,7 +2138,7 @@ class Video(
y = output_file_name
y = self.make_temp_copy_if_needed(y)
return {"name": y, "data": None, "is_file": True}
return {"name": y, "data": None, "is_file": True, "orig_name": Path(y).name}
def style(self, *, height: int | None = None, width: int | None = None, **kwargs):
"""

View File

@ -1292,6 +1292,7 @@ class TestVideo:
assert output1.endswith("mp4")
output2 = video_output.postprocess(y_vid_path)["name"]
assert output1 == output2
assert video_output.postprocess(y_vid_path)["orig_name"] == "video_sample.mp4"
assert video_output.deserialize(
{