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

Allow setting title in gr.Info/Warning/Error #9681

Merged
merged 9 commits into from
Oct 15, 2024
Merged

Conversation

ABucket
Copy link
Contributor

@ABucket ABucket commented Oct 12, 2024

Description

Allow users to manually set the title (i.e. through gr.Info("Message", title="Title").

Closes: #9670

🎯 PRs Should Target Issues

Before your create a PR, please check to see if there is an existing issue for this change. If not, please create an issue before you create this PR, unless the fix is very small.

Not adhering to this guideline will result in the PR being closed.

Tests

  1. PRs will only be merged if tests pass on CI. To run the tests locally, please set up your Gradio environment locally and run the tests: bash scripts/run_all_tests.sh

  2. You may need to run the linters: bash scripts/format_backend.sh and bash scripts/format_frontend.sh

@gradio-pr-bot
Copy link
Collaborator

gradio-pr-bot commented Oct 12, 2024

🪼 branch checks and previews

Name Status URL
Spaces ready! Spaces preview
Website ready! Website preview
Storybook ready! Storybook preview
🦄 Changes detected! Details

Install Gradio from this PR

pip install https://gradio-pypi-previews.s3.amazonaws.com/d7edb5b772f0d5da9ceeda22098ae7e6c7df178c/gradio-5.1.0-py3-none-any.whl

Install Gradio Python Client from this PR

pip install "gradio-client @ git+https://github.com/gradio-app/gradio@d7edb5b772f0d5da9ceeda22098ae7e6c7df178c#subdirectory=client/python"

Install Gradio JS Client from this PR

npm install https://gradio-npm-previews.s3.amazonaws.com/d7edb5b772f0d5da9ceeda22098ae7e6c7df178c/gradio-client-1.6.0.tgz

Use Lite from this PR

<script type="module" src="https://gradio-lite-previews.s3.amazonaws.com/d7edb5b772f0d5da9ceeda22098ae7e6c7df178c/dist/lite.js""></script>

@gradio-pr-bot
Copy link
Collaborator

gradio-pr-bot commented Oct 12, 2024

🦄 change detected

This Pull Request includes changes to the following packages.

Package Version
@gradio/client minor
@gradio/core minor
@gradio/statustracker minor
@self/app minor
@self/spa minor
gradio minor
  • Maintainers can select this checkbox to manually select packages to update.

With the following changelog entry.

Allow setting title in gr.Info/Warning/Error

Maintainers or the PR author can modify the PR title to modify this entry.

Something isn't right?

  • Maintainers can change the version label to modify the version bump.
  • If the bot has failed to detect any changes, or if this pull request needs to update multiple packages to different versions or requires a more comprehensive changelog entry, maintainers can update the changelog file directly.

@ABucket ABucket marked this pull request as draft October 12, 2024 16:26
@ABucket ABucket force-pushed the main branch 2 times, most recently from 66290bc to bcd020d Compare October 12, 2024 16:39
@ABucket ABucket marked this pull request as ready for review October 12, 2024 16:42
Copy link
Collaborator

@freddyaboulton freddyaboulton left a comment

Choose a reason for hiding this comment

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

Looks good @ABucket - I think we need to add a title parameter to gr.Error and we can merge.

@ABucket
Copy link
Contributor Author

ABucket commented Oct 15, 2024

Looks good @ABucket - I think we need to add a title parameter to gr.Error and we can merge.

please check commit 5b26340 @freddyaboulton

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 @ABucket this PR looks great. Just noticed one thing -- the position of the title argument is not consistent across Info, Warning, and Error. For consistency and to allow backwards-compatibility to developers who may have provided these arguments positionally, can you make title the last argument in all of these classes? Thanks!

@ABucket
Copy link
Contributor Author

ABucket commented Oct 15, 2024

Thanks @ABucket this PR looks great. Just noticed one thing -- the position of the title argument is not consistent across Info, Warning, and Error. For consistency and to allow backwards-compatibility to developers who may have provided these arguments positionally, can you make title the last argument in all of these classes? Thanks!

Thanks for your suggestion! Just fixed, please check commit 0c81060

@abidlabs
Copy link
Member

Changes look good, thanks @ABucket. I tested this out and I think it would be better if the title did not support HTML, just a standard string. I'll go ahead and make that change and we can merge this in

@abidlabs abidlabs dismissed their stale review October 15, 2024 16:53

addressed

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.

LGTM! test code:

import gradio as gr
import time

def test():
  time.sleep(1)  
  gr.Info("some info", title="new info")
  time.sleep(1)  
  gr.Warning("some warning", title="new <i>warning</i>")
  time.sleep(1)  
  raise gr.Error("some error", title="new error")

# def test():
#   time.sleep(1)  
#   gr.Info("some info")
#   time.sleep(1)  
#   gr.Warning("some warning")
#   time.sleep(1)  
#   raise gr.Error("some error")

with gr.Blocks() as demo:
  demo.load(test, None, None)

demo.launch()

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.

Great PR, thanks again @ABucket!

@abidlabs abidlabs merged commit 2ed2361 into gradio-app:main Oct 15, 2024
19 of 23 checks passed
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.

Allow setting title in gr.Info/Warning/Error
4 participants