gradio: Please do not remove gr.update()

After updating from gradio 3.33 to 3.47, I noticed that the gr.update method has been deprecated.

I would like to request that this parameter remains part of gradio. Here are some of its use cases:

  1. Hiding an showing elements using events:
lambda: gr.update(visible=True), None, my_element
  1. Making elements interactive or not:
lambda: gr.update(interactive=False), None, my_element
  1. Updating the list of choices for a dropdown and the selected value:
lambda x: gr.update(choices=get_available_characters(), value=x), character_name, character_menu

For complex applications with many components, redeclaring the component each time one of its attributes needs to be updated becomes a major inconvenience.

About this issue

  • Original URL
  • State: closed
  • Created 9 months ago
  • Reactions: 6
  • Comments: 15 (6 by maintainers)

Most upvoted comments

What a nonsense comment, like that whole issue.

I think the best compromise would be to add all the kwargs of gr.IOComponent() to gr.update (interactive, visible, elem_id, etc.), so that type hinting is still provided for these arguments.

Regarding the matter at hand, thanks for explaining @oobabooga. We’ll discuss internally and come up with a plan.

@henryruhs please do not comment disrespectfully on other people’s issues in this manner. Generally, the Gradio repo is a place where we want to have productive and kind conversations. Feedback on issues is appreciated, but being kind, empathetic, and respectful when giving it is also important. Don’t forget there are people at the other side of the screen. If we see these kinds of comments from you again, we’ll have no choice but to block you from the repo.

Python is a dynamically typed language.

Thanks for the clarification @aliabid94. That’s better, but imo there is still a loss in removing gr.update(). Take it for instance here:

https://github.com/oobabooga/text-generation-webui/blob/main/modules/ui.py#L180

This function is used to update all elements in the interface, and gr.update() is key for that.

The syntax is also very readable - gr.update(visible=False) is more readable than gr.Dropdown(visible=False).

If the gr.update() definition takes just a few lines in the Gradio codebase, I would vote for keeping it.