mirror of
https://github.com/gradio-app/gradio.git
synced 2025-03-07 11:46:51 +08:00
Fix view_api bug where unnamed rotes where showing api_name instead of fn_index (#3972)
* Fix view_api bug * Add to changelog * Rework test
This commit is contained in:
parent
37d52a753c
commit
2a59ec04fa
@ -2,11 +2,11 @@
|
||||
|
||||
## New Features:
|
||||
|
||||
- Progress Updates from `gr.Progress()` can be accessed via `job.status().progress_data` by @freddyaboulton](https://github.com/freddyaboulton) in [PR 3924](https://github.com/gradio-app/gradio/pull/3924)
|
||||
- Progress Updates from `gr.Progress()` can be accessed via `job.status().progress_data` by [@freddyaboulton](https://github.com/freddyaboulton) in [PR 3924](https://github.com/gradio-app/gradio/pull/3924)
|
||||
|
||||
## Bug Fixes:
|
||||
|
||||
No changes to highlight.
|
||||
- Fixed bug where unnamed routes where displayed with `api_name` instead of `fn_index` in `view_api` by [@freddyaboulton](https://github.com/freddyaboulton) in [PR 3972](https://github.com/gradio-app/gradio/pull/3972)
|
||||
|
||||
## Documentation Changes:
|
||||
|
||||
|
@ -415,7 +415,6 @@ class Client:
|
||||
info = fetch.json()["api"]
|
||||
else:
|
||||
raise ValueError(f"Could not fetch api info for {self.src}")
|
||||
|
||||
num_named_endpoints = len(info["named_endpoints"])
|
||||
num_unnamed_endpoints = len(info["unnamed_endpoints"])
|
||||
if num_named_endpoints == 0 and all_endpoints is None:
|
||||
@ -430,7 +429,9 @@ class Client:
|
||||
if all_endpoints:
|
||||
human_info += f"\nUnnamed API endpoints: {num_unnamed_endpoints}\n"
|
||||
for fn_index, endpoint_info in info["unnamed_endpoints"].items():
|
||||
human_info += self._render_endpoints_info(fn_index, endpoint_info)
|
||||
# When loading from json, the fn_indices are read as strings
|
||||
# because json keys can only be strings
|
||||
human_info += self._render_endpoints_info(int(fn_index), endpoint_info)
|
||||
else:
|
||||
if num_unnamed_endpoints > 0:
|
||||
human_info += f"\nUnnamed API endpoints: {num_unnamed_endpoints}, to view, run Client.view_api(`all_endpoints=True`)\n"
|
||||
|
@ -667,6 +667,13 @@ class TestAPIInfo:
|
||||
"unnamed_endpoints": {},
|
||||
}
|
||||
|
||||
def test_unnamed_endpoints_use_fn_index(self, count_generator_demo):
|
||||
# This demo has no api_name
|
||||
with connect(count_generator_demo) as client:
|
||||
info = client.view_api(return_format="str")
|
||||
assert "fn_index=0" in info
|
||||
assert "api_name" not in info
|
||||
|
||||
|
||||
class TestEndpoints:
|
||||
def test_upload(self):
|
||||
|
Loading…
Reference in New Issue
Block a user