mirror of
https://github.com/gradio-app/gradio.git
synced 2025-02-23 11:39:17 +08:00
* Update interface.py if the first param is self, trim the param list * Update CHANGELOG.md * update and add test * update and add test --------- Co-authored-by: Abubakar Abid <abubakar@huggingface.co> Co-authored-by: Freddy Boulton <alfonsoboulton@gmail.com>
This commit is contained in:
parent
9fb3c2236d
commit
75a1adee93
@ -30,6 +30,7 @@ No changes to highlight.
|
||||
|
||||
## Bug Fixes:
|
||||
- Ensure uploaded images are always shown in the sketch tool by [@pngwn](https://github.com/pngwn) in [PR 3386](https://github.com/gradio-app/gradio/pull/3386)
|
||||
- Fixes bug where when if fn is a non-static class member, then self should be ignored as the first param of the fn by [@or25](https://github.com/or25) in [PR #3227](https://github.com/gradio-app/gradio/pull/3227)
|
||||
|
||||
## Documentation Changes:
|
||||
No changes to highlight.
|
||||
@ -309,8 +310,8 @@ By [@maxaudron](https://github.com/maxaudron) in [PR 3075](https://github.com/gr
|
||||
- Fixes bug where interactive output image cannot be set when in edit mode by [@dawoodkhan82](https://github.com/@dawoodkhan82) in [PR 3135](https://github.com/gradio-app/gradio/pull/3135)
|
||||
- A share link will automatically be created when running on Sagemaker notebooks so that the front-end is properly displayed by [@abidlabs](https://github.com/abidlabs) in [PR 3137](https://github.com/gradio-app/gradio/pull/3137)
|
||||
- Fixes a few dropdown component issues; hide checkmark next to options as expected, and keyboard hover is visible by [@dawoodkhan82](https://github.com/dawoodkhan82) in [PR 3145]https://github.com/gradio-app/gradio/pull/3145)
|
||||
- Fixed bug where example pagination buttons were not visible in dark mode or displayed under the examples table. By [@freddyaboulton](https://github.com/freddyaboulton) in [PR 3144](https://github.com/gradio-app/gradio/pull/3144)
|
||||
- Fixed bug where the font color of axis labels and titles for native plots did not respond to dark mode preferences. By [@freddyaboulton](https://github.com/freddyaboulton) in [PR 3146](https://github.com/gradio-app/gradio/pull/3146)
|
||||
- Fixed bug where example pagination buttons were not visible in dark mode or displayed under the examples table. By [@freddyaboulton](https://github.com/freddyaboulton) in [PR 3144](https://github.com/gradio-app/gradio/pull/3144)
|
||||
- Fixed bug where the font color of axis labels and titles for native plots did not respond to dark mode preferences. By [@freddyaboulton](https://github.com/freddyaboulton) in [PR 3146](https://github.com/gradio-app/gradio/pull/3146)
|
||||
|
||||
## 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)
|
||||
|
@ -400,6 +400,8 @@ class Interface(Blocks):
|
||||
Interface.instances.add(self)
|
||||
|
||||
param_names = inspect.getfullargspec(self.fn)[0]
|
||||
if len(param_names) > 0 and inspect.ismethod(self.fn):
|
||||
param_names = param_names[1:]
|
||||
for component, param_name in zip(self.input_components, param_names):
|
||||
assert isinstance(component, IOComponent)
|
||||
if component.label is None:
|
||||
|
@ -13,6 +13,7 @@ from fastapi.testclient import TestClient
|
||||
|
||||
import gradio
|
||||
from gradio.blocks import Blocks
|
||||
from gradio.components import Image, Textbox
|
||||
from gradio.interface import Interface, TabbedInterface, close_all, os
|
||||
from gradio.layouts import TabItem, Tabs
|
||||
from gradio.utils import assert_configs_are_equivalent_besides_ids
|
||||
@ -59,6 +60,24 @@ class TestInterface:
|
||||
demo = Interface(fn=greet_upper_case, inputs="text", outputs="text")
|
||||
assert demo("abubakar") == "Hello Abubakar!"
|
||||
|
||||
def test_input_labels_extracted_from_method(self):
|
||||
class A:
|
||||
def test(self, parameter_name):
|
||||
return parameter_name
|
||||
|
||||
t = Textbox()
|
||||
Interface(A().test, t, "text")
|
||||
assert t.label == "parameter_name"
|
||||
|
||||
def test(parameter_name1, parameter_name2):
|
||||
return parameter_name1
|
||||
|
||||
t = Textbox()
|
||||
i = Image()
|
||||
Interface(test, [t, i], "text")
|
||||
assert t.label == "parameter_name1"
|
||||
assert i.label == "parameter_name2"
|
||||
|
||||
def test_examples_valid_path(self):
|
||||
path = os.path.join(
|
||||
os.path.dirname(__file__), "../gradio/test_data/flagged_with_log"
|
||||
|
Loading…
Reference in New Issue
Block a user