Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix view_api bug where unnamed rotes where showing api_name instead of fn_index #3972

Merged
merged 5 commits into from
Apr 26, 2023

Conversation

freddyaboulton
Copy link
Collaborator

@freddyaboulton freddyaboulton commented Apr 25, 2023

Description

Long-winded title but the issue was that unnamed routes were shown with api_name='0' as opposed to fn_index=0, which caused user confusion.

client = Client("stabilityai/stable-diffusion") 
client.view_api()
Client.predict() Usage Info
---------------------------
Named API endpoints: 0

Unnamed API endpoints: 4

...
- predict(enter_your_prompt, enter_your_negative_prompt, guidance_scale, api_name="1") -> generated_images
    Parameters:
     - [Textbox] enter_your_prompt: str (string value)
     - [Textbox] enter_your_negative_prompt: str (string value)
     - [Slider] guidance_scale: int | float (numeric value)
    Returns:
     - [Gallery] generated_images: str (path to directory with images and a file associating images with captions called captions.json)
...

Checklist:

  • I have performed a self-review of my own code
  • I have added a short summary of my change to the CHANGELOG.md
  • My code follows the style guidelines of this project
  • I have commented my code in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

A note about the CHANGELOG

Hello 👋 and thank you for contributing to Gradio!

All pull requests must update the change log located in CHANGELOG.md, unless the pull request is labeled with the "no-changelog-update" label.

Please add a brief summary of the change to the Upcoming Release > Full Changelog section of the CHANGELOG.md file and include
a link to the PR (formatted in markdown) and a link to your github profile (if you like). For example, "* Added a cool new feature by [@myusername](link-to-your-github-profile) in [PR 11111](https://github.com/gradio-app/gradio/pull/11111)".

If you would like to elaborate on your change further, feel free to include a longer explanation in the other sections.
If you would like an image/gif/video showcasing your feature, it may be best to edit the CHANGELOG file using the
GitHub web UI since that lets you upload files directly via drag-and-drop.

@gradio-pr-bot
Copy link
Collaborator

All the demos for this PR have been deployed at https://huggingface.co/spaces/gradio-pr-deploys/pr-3972-all-demos

@freddyaboulton freddyaboulton marked this pull request as ready for review April 25, 2023 20:38

Unnamed API endpoints: 1

- predict(parameter1, fn_index=0) -> value2
Copy link
Member

@abidlabs abidlabs Apr 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion, maybe just check if "fn_index=0" is in the string, as the format of the view_api(return_format="str") may change and we don't want this test to be welded too tightly to the format

(this would also fix the failing test)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed now @abidlabs ! Thanks

@freddyaboulton freddyaboulton force-pushed the fix-api-info-unnamed-routes-python-client branch from 4d0829b to e9de30e Compare April 26, 2023 15:24
@abidlabs
Copy link
Member

Thanks @freddyaboulton for the fix!

@freddyaboulton freddyaboulton merged commit 2a59ec0 into main Apr 26, 2023
@freddyaboulton freddyaboulton deleted the fix-api-info-unnamed-routes-python-client branch April 26, 2023 22:38
@pngwn pngwn mentioned this pull request Jul 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants