Skip to content

Commit

Permalink
Respect interactive=True in output of gr.Interface (#4356)
Browse files Browse the repository at this point in the history
* tests

* changelog

* lint

* Update gradio/interface.py

Co-authored-by: Aarni Koskela <akx@iki.fi>

* format

---------

Co-authored-by: Aarni Koskela <akx@iki.fi>
  • Loading branch information
abidlabs and akx authored May 30, 2023
1 parent 0a6a80c commit fc3bbca
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

## New Features:

* Make `Blocks.load` behave like other event listeners (allows chaining `then` off of it) [@anentropic](https://github.com/anentropic/) in [PR 4304](https://github.com/gradio-app/gradio/pull/4304)

## Bug Fixes:

- Make `Blocks.load` behave like other event listeners (allows chaining `then` off of it) [@anentropic](https://github.com/anentropic/) in [PR 4304](https://github.com/gradio-app/gradio/pull/4304)
- Respect `interactive=True` in output components of a `gr.Interface` by [@abidlabs](https://github.com/abidlabs) in [PR 4356](https://github.com/gradio-app/gradio/pull/4356).
- Remove unused frontend code by [@akx](https://github.com/akx) in [PR 4275](https://github.com/gradio-app/gradio/pull/4275)

## Other Changes:
Expand Down
6 changes: 4 additions & 2 deletions gradio/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,10 @@ def __init__(
]:
for o in self.output_components:
assert isinstance(o, IOComponent)
o.interactive = False # Force output components to be non-interactive

if o.interactive is None:
# Unless explicitly otherwise specified, force output components to
# be non-interactive
o.interactive = False
if (
interpretation is None
or isinstance(interpretation, list)
Expand Down
8 changes: 8 additions & 0 deletions test/test_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,14 @@ def test_inline_display(self, mock_display):
assert mock_display.call_count == 2
interface.close()

def test_setting_interactive_false(self):
output_textbox = Textbox()
Interface(lambda x: x, "textbox", output_textbox)
assert not output_textbox.get_config()["interactive"]
output_textbox = Textbox(interactive=True)
Interface(lambda x: x, "textbox", output_textbox)
assert output_textbox.get_config()["interactive"]


class TestTabbedInterface:
def test_tabbed_interface_config_matches_manual_tab(self):
Expand Down

0 comments on commit fc3bbca

Please sign in to comment.