mirror of
https://github.com/gradio-app/gradio.git
synced 2025-04-06 12:30:29 +08:00
Optimize client view_api method (#7178)
* Re-order code * add changeset --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
This commit is contained in:
parent
ded5256c4a
commit
9f23b0bc54
6
.changeset/easy-flowers-nail.md
Normal file
6
.changeset/easy-flowers-nail.md
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
"gradio": patch
|
||||
"gradio_client": patch
|
||||
---
|
||||
|
||||
fix:Optimize client view_api method
|
@ -146,7 +146,7 @@ class Client:
|
||||
self.upload_url = urllib.parse.urljoin(self.src, utils.UPLOAD_URL)
|
||||
self.reset_url = urllib.parse.urljoin(self.src, utils.RESET_URL)
|
||||
self.app_version = version.parse(self.config.get("version", "2.0"))
|
||||
self._info = self._get_api_info()
|
||||
self._info = None
|
||||
self.session_hash = str(uuid.uuid4())
|
||||
|
||||
endpoint_class = (
|
||||
@ -556,6 +556,8 @@ class Client:
|
||||
}
|
||||
|
||||
"""
|
||||
if not self._info:
|
||||
self._info = self._get_api_info()
|
||||
num_named_endpoints = len(self._info["named_endpoints"])
|
||||
num_unnamed_endpoints = len(self._info["unnamed_endpoints"])
|
||||
if num_named_endpoints == 0 and all_endpoints is None:
|
||||
|
@ -2304,12 +2304,9 @@ Received outputs:
|
||||
if self.blocks[component["id"]].skip_api:
|
||||
continue
|
||||
label = component["props"].get("label", f"parameter_{i}")
|
||||
# The config has the most specific API info (taking into account the parameters
|
||||
# of the component), so we use that if it exists. Otherwise, we fallback to the
|
||||
# Serializer's API info.
|
||||
comp = self.get_component(component["id"])
|
||||
assert isinstance(comp, components.Component)
|
||||
info = comp.api_info()
|
||||
info = component["api_info"]
|
||||
example = comp.example_inputs()
|
||||
python_type = client_utils.json_schema_to_python_type(info)
|
||||
dependency_info["parameters"].append(
|
||||
@ -2339,7 +2336,7 @@ Received outputs:
|
||||
label = component["props"].get("label", f"value_{o}")
|
||||
comp = self.get_component(component["id"])
|
||||
assert isinstance(comp, components.Component)
|
||||
info = comp.api_info()
|
||||
info = component["api_info"]
|
||||
example = comp.example_inputs()
|
||||
python_type = client_utils.json_schema_to_python_type(info)
|
||||
dependency_info["returns"].append(
|
||||
|
Loading…
x
Reference in New Issue
Block a user