Emit warning when using an interface in reload mode (#3126)

* Add warning

* CHANGELOG

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
This commit is contained in:
Freddy Boulton 2023-02-06 10:00:35 -05:00 committed by GitHub
parent 84afc51484
commit 50d24a854e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -29,10 +29,11 @@ By [@maxaudron](https://github.com/maxaudron) in [PR 3075](https://github.com/gr
- Fixes URL resolution on Windows by [@abidlabs](https://github.com/abidlabs) in [PR 3108](https://github.com/gradio-app/gradio/pull/3108)
- Example caching now works with components without a label attribute (e.g. `Column`) by [@abidlabs](https://github.com/abidlabs) in [PR 3123](https://github.com/gradio-app/gradio/pull/3123)
- Ensure the Video component correctly resets the UI state whe a new video source is loaded and reduce choppiness of UI by [@pngwn](https://github.com/abidlabs) in [PR 3117](https://github.com/gradio-app/gradio/pull/3117)
- Added a warning when attempting to launch an `Interface` via the `%%blocks` jupyter notebook magic command by [@freddyaboulton](https://github.com/freddyaboulton) in [PR 3126](https://github.com/gradio-app/gradio/pull/3126)
## Documentation Changes:
- Added a guide on the 4 kinds of Gradio Interfaces by [@yvrjsharma](https://github.com/yvrjsharma) and [@abidlabs](https://github.com/abidlabs) in [PR 3003](https://github.com/gradio-app/gradio/pull/3003)
* Explained that the parameters in `launch` will not be respected when using reload mode, e.g. `gradio` command by [@freddyaboulton](https://github.com/freddyaboulton) in [PR 3089](https://github.com/gradio-app/gradio/pull/3089)
* Explained that the parameters in `launch` will not be respected when using reload mode, e.g. `gradio` command by [@freddyaboulton](https://github.com/freddyaboulton) in [PR 3089](https://github.com/gradio-app/gradio/pull/3089)
## Testing and Infrastructure Changes:
No changes to highlight.

View File

@ -3,6 +3,8 @@ try:
except ImportError:
pass
import warnings
import gradio
@ -12,6 +14,8 @@ def load_ipython_extension(ipython):
@register_cell_magic
@needs_local_scope
def blocks(line, cell, local_ns=None):
if "gr.Interface" in cell:
warnings.warn("Usage of gr.Interface with %%blocks may result in errors.")
with __demo.clear():
exec(cell, None, local_ns)
__demo.launch(quiet=True)