From 7ef0439d3c2aef968f8d750447284a06a06fb447 Mon Sep 17 00:00:00 2001 From: Freddy Boulton Date: Fri, 14 Apr 2023 17:07:19 -0700 Subject: [PATCH] Fix video serializing in client (#3860) * Fix video serializing in client * Add to changelog * Remove print --- client/python/CHANGELOG.md | 2 +- client/python/gradio_client/serializing.py | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/client/python/CHANGELOG.md b/client/python/CHANGELOG.md index 7f2da32bf9..7cdd4026ce 100644 --- a/client/python/CHANGELOG.md +++ b/client/python/CHANGELOG.md @@ -6,7 +6,7 @@ No changes to highlight. ## Bug Fixes: -No changes to highlight. +- Fixed bug where `Video` components in latest gradio were not able to be deserialized by [@freddyaboulton](https://github.com/freddyaboulton) in [PR 3860](https://github.com/gradio-app/gradio/pull/3860) ## Documentation Changes: diff --git a/client/python/gradio_client/serializing.py b/client/python/gradio_client/serializing.py index 566e53e4df..d313256d1f 100644 --- a/client/python/gradio_client/serializing.py +++ b/client/python/gradio_client/serializing.py @@ -368,7 +368,7 @@ class VideoSerializable(FileSerializable): Convert from serialized representation of a file (base64) to a human-friendly version (string filepath). Optionally, save the file to the directory specified by `save_dir` """ - if isinstance(x, tuple): + if isinstance(x, (tuple, list)): assert len(x) == 2, f"Expected tuple of length 2. Received: {x}" x_as_list = [x[0], x[1]] else: @@ -501,7 +501,12 @@ class GallerySerializable(Serializable): return os.path.abspath(gallery_path) -SERIALIZER_MAPPING = {cls.__name__: cls for cls in Serializable.__subclasses__()} +SERIALIZER_MAPPING = {} +for cls in Serializable.__subclasses__(): + SERIALIZER_MAPPING[cls.__name__] = cls + for subcls in cls.__subclasses__(): + SERIALIZER_MAPPING[subcls.__name__] = subcls + SERIALIZER_MAPPING["Serializable"] = SimpleSerializable SERIALIZER_MAPPING["File"] = FileSerializable SERIALIZER_MAPPING["UploadButton"] = FileSerializable