From c07207e0bc98cc32b6db629c432fadf877e451ff Mon Sep 17 00:00:00 2001 From: Abubakar Abid Date: Wed, 11 Oct 2023 11:51:16 -0700 Subject: [PATCH] Remove deprecated `.update()` usage from Interface internals (#5862) * remove deprecated .update() usage from Interface * add changeset * add changeset * builder app --------- Co-authored-by: gradio-pr-bot --- .changeset/spicy-cycles-send.md | 5 +++++ gradio/flagging.py | 2 +- gradio/interface.py | 16 ++++++++-------- gradio/themes/builder_app.py | 4 ++-- 4 files changed, 16 insertions(+), 11 deletions(-) create mode 100644 .changeset/spicy-cycles-send.md diff --git a/.changeset/spicy-cycles-send.md b/.changeset/spicy-cycles-send.md new file mode 100644 index 000000000000..783f2d409028 --- /dev/null +++ b/.changeset/spicy-cycles-send.md @@ -0,0 +1,5 @@ +--- +"gradio": patch +--- + +feat:Remove deprecated `.update()` usage from Interface internals diff --git a/gradio/flagging.py b/gradio/flagging.py index 465982f43dd2..a226fb8d50e4 100644 --- a/gradio/flagging.py +++ b/gradio/flagging.py @@ -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) diff --git a/gradio/interface.py b/gradio/interface.py index b2fe192eb832..c4534e35a197 100644 --- a/gradio/interface.py +++ b/gradio/interface.py @@ -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], @@ -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, @@ -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 []) )} """, ) @@ -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, @@ -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]: diff --git a/gradio/themes/builder_app.py b/gradio/themes/builder_app.py index eecee525366c..742adfafa43a 100644 --- a/gradio/themes/builder_app.py +++ b/gradio/themes/builder_app.py @@ -966,7 +966,7 @@ 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, ), @@ -974,7 +974,7 @@ def upload_to_hub(data): ) except Exception as e: return ( - gr.Markdown.update( + gr.Markdown( value=f"Error: {e}", visible=True, ),