-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Pass any visible error modals from a Gradio app downstream to the app that has gr.load
-ed it
#11043
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
Conversation
🪼 branch checks and previews
Install Gradio from this PR pip install https://gradio-pypi-previews.s3.amazonaws.com/f9007915d2dcacea007f193a72d4e93867a076be/gradio-5.25.2-py3-none-any.whl Install Gradio Python Client from this PR pip install "gradio-client @ git+https://github.com/gradio-app/gradio@f9007915d2dcacea007f193a72d4e93867a076be#subdirectory=client/python" Install Gradio JS Client from this PR npm install https://gradio-npm-previews.s3.amazonaws.com/f9007915d2dcacea007f193a72d4e93867a076be/gradio-client-1.14.2.tgz Use Lite from this PR <script type="module" src="https://gradio-lite-previews.s3.amazonaws.com/f9007915d2dcacea007f193a72d4e93867a076be/dist/lite.js""></script> |
🦄 change detectedThis Pull Request includes changes to the following packages.
With the following changelog entry.
Maintainers or the PR author can modify the PR title to modify this entry.
|
gr.load
-ed it
Tested and working as expected : https://huggingface.co/spaces/cbensimon/gr-load-test But for some reason the app itself is not working properly (not related to this PR). If you try it you'll see that the generated image gets a 404 not found (maybe that the Space targeted by gr.load is using a too old Gradio) |
Thanks @cbensimon for testing and confirming! I'll take a look at that Space when I get a chance |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
@@ -57,7 +58,7 @@ class GradioVersionIncompatibleError(Exception): | |||
|
|||
|
|||
@document(documentation_group="modals") | |||
class Error(Exception): | |||
class Error(AppError): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit but I think AppError should subclass Exception
instead of ValueError
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably right, but I don't think it's a big deal and would be a breaking change for anyone building on top of the Gradio Client who's catching a ValueError. I've added it here: #10471
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think if you're trying to catch AppErrors in your client code, you would catch AppError explicitly as opposed to catching ValueErrors generally but sound good it's a minor point!
gradio/utils.py
Outdated
if show_error: | ||
if isinstance(error, Error): | ||
if isinstance(error, (Error, AppError)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't it just be AppError if Error inherits from AppError?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
Oops thought I had approved before |
Thanks folks! |
Suppose Gradio app A uses
gr.load()
to load a Gradio app B.With this change, if Gradio app B raises a visible error, which means either:
gr.Error
, orshow_error=True
inlaunch()
Then, the error will be visible in Gradio app B (with the usual error modal).
Test with:
and try doing 0/0 for example.
Closes: #10364
cc @cbensimon for visibility