mirror of
https://github.com/gradio-app/gradio.git
synced 2025-02-23 11:39:17 +08:00
Fix interpretation events (#2993)
* Fix interpretation + test * Changelog * Empty * Fix test * Handle None case Co-authored-by: Abubakar Abid <abubakar@huggingface.co> * lint Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
This commit is contained in:
parent
5c32ba31ba
commit
7ebe79a987
@ -4,6 +4,7 @@
|
||||
No changes to highlight.
|
||||
|
||||
## Bug Fixes:
|
||||
* Fixes bug where interpretation event was not configured correctly by [@freddyaboulton](https://github.com/freddyaboulton) in [PR 2993](https://github.com/gradio-app/gradio/pull/2993)
|
||||
* Fix relative import bug in reload mode by [@freddyaboulton](https://github.com/freddyaboulton) in [PR 2992](https://github.com/gradio-app/gradio/pull/2992)
|
||||
|
||||
## Documentation Changes:
|
||||
|
@ -706,8 +706,7 @@ class Interface(Blocks):
|
||||
interpretation_btn.click(
|
||||
self.interpret_func,
|
||||
inputs=self.input_components + self.output_components,
|
||||
outputs=interpretation_set
|
||||
or [] + [input_component_column, interpret_component_column], # type: ignore
|
||||
outputs=(interpretation_set or []) + [input_component_column, interpret_component_column], # type: ignore
|
||||
preprocess=False,
|
||||
)
|
||||
|
||||
|
@ -238,6 +238,34 @@ class TestInterfaceInterpretation:
|
||||
interpretation="default",
|
||||
)
|
||||
|
||||
interpretation_id = None
|
||||
for c in iface.config["components"]:
|
||||
if c["props"].get("value") == "Interpret" and c.get("type") == "button":
|
||||
interpretation_id = c["id"]
|
||||
|
||||
# Make sure the event is configured correctly.
|
||||
interpretation_dep = next(
|
||||
d
|
||||
for d in iface.config["dependencies"]
|
||||
if d["targets"] == [interpretation_id]
|
||||
)
|
||||
interpretation_comps = [
|
||||
c["id"]
|
||||
for c in iface.config["components"]
|
||||
if c.get("type") == "interpretation"
|
||||
]
|
||||
interpretation_columns = [
|
||||
c["id"]
|
||||
for c in iface.config["components"]
|
||||
if c.get("type") == "column" and c["props"].get("variant") == "default"
|
||||
]
|
||||
assert sorted(interpretation_dep["outputs"]) == sorted(
|
||||
interpretation_comps + interpretation_columns
|
||||
)
|
||||
assert sorted(interpretation_dep["inputs"]) == sorted(
|
||||
[c._id for c in iface.input_components + iface.output_components]
|
||||
)
|
||||
|
||||
app, _, _ = iface.launch(prevent_thread_lock=True)
|
||||
client = TestClient(app)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user