Skip to content

Commit

Permalink
Fixes TabbedInterface bug where only first interface events get trigg…
Browse files Browse the repository at this point in the history
…ered (#8504)

* Add code

* add changeset

* Add code

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
  • Loading branch information
freddyaboulton and gradio-pr-bot authored Jun 9, 2024
1 parent ffd53fa commit 2a59bab
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/pretty-clowns-fall.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"gradio": patch
---

fix:Fixes TabbedInterface bug where only first interface events get triggered
1 change: 1 addition & 0 deletions gradio/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1355,6 +1355,7 @@ def render(self):
if isinstance(dep.api_name, str)
]
for dependency in self.fns.values():
dependency._id += dependency_offset
api_name = dependency.api_name
if isinstance(api_name, str):
api_name_ = utils.append_unique_suffix(
Expand Down
12 changes: 12 additions & 0 deletions test/test_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,3 +263,15 @@ def test_live_interface_sets_always_last():
assert dep["trigger_mode"] == "always_last"
return
raise AssertionError("No change dependency found")


def test_tabbed_interface_predictions(connect):
hello_world = gradio.Interface(lambda name: "Hello " + name, "text", "text")
bye_world = gradio.Interface(lambda name: "Bye " + name, "text", "text")

demo = gradio.TabbedInterface(
[hello_world, bye_world], ["Hello World", "Bye World"]
)
with connect(demo) as client:
assert client.predict("Emily", api_name="/predict") == "Hello Emily"
assert client.predict("Hannah", api_name="/predict") == "Hello Hannah"

0 comments on commit 2a59bab

Please sign in to comment.