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

More proper deprecation warnings #4694

Merged
merged 10 commits into from Jun 27, 2023

Conversation

akx
Copy link
Contributor

@akx akx commented Jun 27, 2023

Description

This PR improves and deduplicates a whole bunch of deprecation warnings around Gradio, following up on #4203, by:

  • adding some plumbing:
    • a new GradioDeprecationWarning warning class (since DeprecationWarnings aren't visible by default)
    • a find_user_stack_level helper inspired by Pandas' similar helper that allows an user of warnings.warn() to find the first user code stack level (so warnings point at user code, not at Gradio internals)
  • refactoring:

The end result is that the user gets pinpointed warnings, e.g.

modules/ui.py:1058: GradioDeprecationWarning: The `style` method is deprecated. Please set these arguments in the constructor instead.
  with gr.Row().style(equal_height=False):
modules/ui.py:1090: GradioDeprecationWarning: The `style` method is deprecated. Please set these arguments in the constructor instead.
  with gr.Row().style(equal_height=False):

instead of having to hunt around for these around their codebase since a single warning is only shown once by default.

Also, there's less code than before, in total.

🎯 PRs Should Target Issues

This PR does not target an issue, since this was yet another small annoyance I came across while attempting to upgrade Gradio in the stable-diffusion-webui project.

I can create an issue to say that "warnings aren't helpful", if that... helps.

@gradio-pr-bot
Copy link
Contributor

All the demos for this PR have been deployed at https://huggingface.co/spaces/gradio-pr-deploys/pr-4694-all-demos

Copy link
Member

@abidlabs abidlabs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @akx! LGTM + appreciate the more helpful warnings

@abidlabs abidlabs merged commit 9c551c3 into gradio-app:main Jun 27, 2023
11 checks passed
@akx akx deleted the proper-deprecation-warnings branch June 27, 2023 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants