Skip to content

Commit 2a59bab

Browse files
Fixes TabbedInterface bug where only first interface events get triggered (#8504)
* Add code * add changeset * Add code --------- Co-authored-by: gradio-pr-bot <[email protected]>
1 parent ffd53fa commit 2a59bab

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

.changeset/pretty-clowns-fall.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"gradio": patch
3+
---
4+
5+
fix:Fixes TabbedInterface bug where only first interface events get triggered

gradio/blocks.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1355,6 +1355,7 @@ def render(self):
13551355
if isinstance(dep.api_name, str)
13561356
]
13571357
for dependency in self.fns.values():
1358+
dependency._id += dependency_offset
13581359
api_name = dependency.api_name
13591360
if isinstance(api_name, str):
13601361
api_name_ = utils.append_unique_suffix(

test/test_interfaces.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,3 +263,15 @@ def test_live_interface_sets_always_last():
263263
assert dep["trigger_mode"] == "always_last"
264264
return
265265
raise AssertionError("No change dependency found")
266+
267+
268+
def test_tabbed_interface_predictions(connect):
269+
hello_world = gradio.Interface(lambda name: "Hello " + name, "text", "text")
270+
bye_world = gradio.Interface(lambda name: "Bye " + name, "text", "text")
271+
272+
demo = gradio.TabbedInterface(
273+
[hello_world, bye_world], ["Hello World", "Bye World"]
274+
)
275+
with connect(demo) as client:
276+
assert client.predict("Emily", api_name="/predict") == "Hello Emily"
277+
assert client.predict("Hannah", api_name="/predict") == "Hello Hannah"

0 commit comments

Comments
 (0)