mirror of
https://github.com/gradio-app/gradio.git
synced 2025-04-12 12:40:29 +08:00
Adds missing components to gradio client serializing's component mapping (#4167)
* add missing serialization * format * update release note format * update release note format * fix test
This commit is contained in:
parent
c4a884a9a7
commit
e6198752c6
@ -1,5 +1,36 @@
|
||||
# Upcoming Release
|
||||
|
||||
# 0.2.4
|
||||
|
||||
## New Features:
|
||||
|
||||
No changes to highlight.
|
||||
|
||||
## Bug Fixes:
|
||||
- Fixes missing serialization classes for several components: `Barplot`, `Lineplot`, `Scatterplot`, `AnnotatedImage`, `Interpretation` by [@abidlabs](https://github.com/freddyaboulton) in [PR 4167](https://github.com/gradio-app/gradio/pull/4167)
|
||||
|
||||
## Documentation Changes:
|
||||
|
||||
No changes to highlight.
|
||||
|
||||
## Testing and Infrastructure Changes:
|
||||
|
||||
No changes to highlight.
|
||||
|
||||
## Breaking Changes:
|
||||
|
||||
No changes to highlight.
|
||||
|
||||
## Full Changelog:
|
||||
|
||||
No changes to highlight.
|
||||
|
||||
## Contributors Shoutout:
|
||||
|
||||
No changes to highlight.
|
||||
|
||||
# 0.2.3
|
||||
|
||||
## New Features:
|
||||
|
||||
No changes to highlight.
|
||||
|
@ -541,7 +541,12 @@ COMPONENT_MAPPING: dict[str, type] = {
|
||||
"chatbot": JSONSerializable,
|
||||
"model3d": FileSerializable,
|
||||
"plot": JSONSerializable,
|
||||
"barplot": JSONSerializable,
|
||||
"lineplot": JSONSerializable,
|
||||
"scatterplot": JSONSerializable,
|
||||
"markdown": StringSerializable,
|
||||
"dataset": StringSerializable,
|
||||
"code": StringSerializable,
|
||||
"interpretation": SimpleSerializable,
|
||||
"annotatedimage": JSONSerializable,
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
0.2.3
|
||||
0.2.4
|
||||
|
@ -1,3 +1,4 @@
|
||||
import inspect
|
||||
import random
|
||||
import time
|
||||
|
||||
@ -178,3 +179,24 @@ def file_io_demo():
|
||||
)
|
||||
|
||||
return demo
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def all_components():
|
||||
classes_to_check = gr.components.Component.__subclasses__()
|
||||
subclasses = []
|
||||
|
||||
while classes_to_check:
|
||||
subclass = classes_to_check.pop()
|
||||
children = subclass.__subclasses__()
|
||||
|
||||
if children:
|
||||
classes_to_check.extend(children)
|
||||
if (
|
||||
"value" in inspect.signature(subclass).parameters
|
||||
and subclass != gr.components.IOComponent
|
||||
and not getattr(subclass, "is_template", False)
|
||||
):
|
||||
subclasses.append(subclass)
|
||||
|
||||
return subclasses
|
||||
|
@ -21,12 +21,18 @@ def test_duplicate(serializer_class):
|
||||
|
||||
def test_check_component_fallback_serializers():
|
||||
for component_name, class_type in COMPONENT_MAPPING.items():
|
||||
if component_name == "dataset": # cannot be instantiated without parameters
|
||||
# skip components that cannot be instantiated without parameters
|
||||
if component_name in ["dataset", "interpretation"]:
|
||||
continue
|
||||
component = components.get_component_instance(component_name)
|
||||
assert isinstance(component, class_type)
|
||||
|
||||
|
||||
def test_all_components_in_component_mapping(all_components):
|
||||
for component in all_components:
|
||||
assert component.__name__.lower() in COMPONENT_MAPPING
|
||||
|
||||
|
||||
def test_file_serializing():
|
||||
|
||||
try:
|
||||
|
@ -12,22 +12,12 @@ No changes to highlight.
|
||||
## Bug Fixes:
|
||||
No changes to highlight.
|
||||
|
||||
## Documentation Changes:
|
||||
No changes to highlight.
|
||||
|
||||
## Testing and Infrastructure Changes:
|
||||
## Other Changes:
|
||||
No changes to highlight.
|
||||
|
||||
## Breaking Changes:
|
||||
No changes to highlight.
|
||||
|
||||
## Full Changelog:
|
||||
No changes to highlight.
|
||||
|
||||
## Contributors Shoutout:
|
||||
No changes to highlight.
|
||||
|
||||
|
||||
"""
|
||||
|
||||
|
||||
|
@ -1474,10 +1474,9 @@ class TestTimeseries:
|
||||
|
||||
class TestNames:
|
||||
# This test ensures that `components.get_component_instance()` works correctly when instantiating from components
|
||||
def test_no_duplicate_uncased_names(self):
|
||||
subclasses = gr.components.Component.__subclasses__()
|
||||
unique_subclasses_uncased = {s.__name__.lower() for s in subclasses}
|
||||
assert len(subclasses) == len(unique_subclasses_uncased)
|
||||
def test_no_duplicate_uncased_names(self, io_components):
|
||||
unique_subclasses_uncased = {s.__name__.lower() for s in io_components}
|
||||
assert len(io_components) == len(unique_subclasses_uncased)
|
||||
|
||||
|
||||
class TestLabel:
|
||||
|
Loading…
x
Reference in New Issue
Block a user