-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* clean-deprecated-parameters - resolve conflicts * clean-deprecated-parameters - fix tests * clean-deprecated-parameters - fix tests * clean-deprecated-parameters - resolve conflicts * clean-deprecated-parameters - refactor blocks.py * clean-deprecated-parameters - remove capture_session support * clean-deprecated-parameters - fix get_component_instance * clean-deprecated-parameters - fix tests * clean-deprecated-parameters - reformat * clean-deprecated-parameters - fix tests * clean-deprecated-parameters - fix tests * clean-deprecated-parameters - resolve conflicts * clean-deprecated-parameters - resolve conflicts * Update gradio/deprecation.py * Update gradio/deprecation.py * Update gradio/deprecation.py * removed some incorrect kwargs * formatting Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
- Loading branch information
1 parent
f856869
commit 930c4a3
Showing
13 changed files
with
113 additions
and
1,589 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import warnings | ||
|
||
|
||
def simple_deprecated_notice(term: str) -> str: | ||
return f"`{term}` parameter is deprecated, and it has no effect" | ||
|
||
|
||
def use_in_launch(term: str) -> str: | ||
return f"`{term}` is deprecated in `Interface()`, please use it within `launch()` instead." | ||
|
||
|
||
DEPRECATION_MESSAGE = { | ||
"optional": simple_deprecated_notice("optional"), | ||
"keep_filename": simple_deprecated_notice("keep_filename"), | ||
"numeric": simple_deprecated_notice("numeric"), | ||
"verbose": simple_deprecated_notice("verbose"), | ||
"allow_screenshot": simple_deprecated_notice("allow_screenshot"), | ||
"capture_session": simple_deprecated_notice("capture_session"), | ||
"api_mode": simple_deprecated_notice("api_mode"), | ||
"show_tips": use_in_launch("show_tips"), | ||
"encrypt": use_in_launch("encrypt"), | ||
"enable_queue": use_in_launch("enable_queue"), | ||
"server_name": use_in_launch("server_name"), | ||
"server_port": use_in_launch("server_port"), | ||
"width": use_in_launch("width"), | ||
"height": use_in_launch("height"), | ||
"plot": "The 'plot' parameter has been deprecated. Use the new Plot component instead", | ||
"type": "The 'type' parameter has been deprecated. Use the Number component instead.", | ||
} | ||
|
||
|
||
def check_deprecated_parameters(cls: str, **kwargs) -> None: | ||
for key, value in DEPRECATION_MESSAGE.items(): | ||
if key in kwargs: | ||
kwargs.pop(key) | ||
# Interestingly, using DeprecationWarning causes warning to not appear. | ||
warnings.warn(value) | ||
|
||
if len(kwargs) != 0: | ||
warnings.warn( | ||
f"You have unused kwarg parameters in {cls}, please remove them: {kwargs}" | ||
) |
Oops, something went wrong.