Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated .update() usage from Interface internals #5862

Merged
merged 5 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/spicy-cycles-send.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"gradio": patch
---

feat:Remove deprecated `.update()` usage from Interface internals
2 changes: 1 addition & 1 deletion gradio/flagging.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,4 +523,4 @@ def __call__(self, request: gr.Request, *flag_data):
return self.reset()

def reset(self):
return gr.Button.update(value=self.label, interactive=True)
return gr.Button(value=self.label, interactive=True)
16 changes: 8 additions & 8 deletions gradio/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -661,13 +661,13 @@ def attach_submit_events(self, submit_btn: Button | None, stop_btn: Button | Non
extra_output = [submit_btn, stop_btn]

def cleanup():
return [Button.update(visible=True), Button.update(visible=False)]
return [Button(visible=True), Button(visible=False)]

predict_event = on(
triggers,
lambda: (
submit_btn.update(visible=False),
stop_btn.update(visible=True),
Button(visible=False),
Button(visible=True),
),
inputs=None,
outputs=[submit_btn, stop_btn],
Expand Down Expand Up @@ -728,7 +728,7 @@ def attach_clear_events(
), # type: ignore
_js=f"""() => {json.dumps(
(
[Column.update(visible=True)]
[{'variant': None, 'visible': True, '__type__': 'update'}]
if self.interface_type
in [
InterfaceTypes.STANDARD,
Expand All @@ -737,7 +737,7 @@ def attach_clear_events(
]
else []
)
+ ([Column.update(visible=False)] if self.interpretation else [])
+ ([{'variant': None, 'visible': False, '__type__': 'update'}] if self.interpretation else [])
)}
""",
)
Expand Down Expand Up @@ -793,7 +793,7 @@ def attach_flagging_events(
assert isinstance(value, str)
flag_method = FlagMethod(self.flagging_callback, label, value)
flag_btn.click(
lambda: Button.update(value="Saving...", interactive=False),
lambda: Button(value="Saving...", interactive=False),
None,
flag_btn,
queue=False,
Expand Down Expand Up @@ -847,8 +847,8 @@ def __repr__(self):

async def interpret_func(self, *args):
return await self.interpret(list(args)) + [
Column.update(visible=False),
Column.update(visible=True),
Column(visible=False),
Column(visible=True),
]

async def interpret(self, raw_input: list[Any]) -> list[Any]:
Expand Down
4 changes: 2 additions & 2 deletions gradio/themes/builder_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -966,15 +966,15 @@ def upload_to_hub(data):
)
space_name = "/".join(theme_url.split("/")[-2:])
return (
gr.Markdown.update(
gr.Markdown(
value=f"Theme uploaded [here!]({theme_url})! Load it as `gr.Blocks(theme='{space_name}')`",
visible=True,
),
"Upload to Hub",
)
except Exception as e:
return (
gr.Markdown.update(
gr.Markdown(
value=f"Error: {e}",
visible=True,
),
Expand Down
Loading