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

Cache view_api info in server and python client #7888

Merged
merged 3 commits into from Mar 29, 2024

Conversation

freddyaboulton
Copy link
Collaborator

Description

Closes: #7882

The client will call the api info endpoint only once during initialization. The server caches the result because right now it should not change throughout the lifetime of the app. This is for the case where many clients connect to view the api info simultaneously.

🎯 PRs Should Target Issues

Before your create a PR, please check to see if there is an existing issue for this change. If not, please create an issue before you create this PR, unless the fix is very small.

Not adhering to this guideline will result in the PR being closed.

Tests

  1. PRs will only be merged if tests pass on CI. To run the tests locally, please set up your Gradio environment locally and run the tests: bash scripts/run_all_tests.sh

  2. You may need to run the linters: bash scripts/format_backend.sh and bash scripts/format_frontend.sh

@freddyaboulton freddyaboulton added the v: patch A change that requires a patch release label Mar 29, 2024
@freddyaboulton freddyaboulton marked this pull request as ready for review March 29, 2024 16:57
@gradio-pr-bot
Copy link
Contributor

gradio-pr-bot commented Mar 29, 2024

🪼 branch checks and previews

Name Status URL
Spaces ready! Spaces preview
Website ready! Website preview
🦄 Changes detecting...

Install Gradio from this PR

pip install https://gradio-builds.s3.amazonaws.com/ee0da9a1d4b94c42b84c798da0fb1b765172d673/gradio-4.24.0-py3-none-any.whl

Install Gradio Python Client from this PR

pip install "gradio-client @ git+https://github.com/gradio-app/gradio@ee0da9a1d4b94c42b84c798da0fb1b765172d673#subdirectory=client/python"

@gradio-pr-bot
Copy link
Contributor

🦄 change detected

This Pull Request includes changes to the following packages.

Package Version
gradio patch
gradio_client patch
  • Maintainers can select this checkbox to manually select packages to update.

With the following changelog entry.

Cache view_api info in server and python client

Maintainers or the PR author can modify the PR title to modify this entry.

Something isn't right?

  • Maintainers can change the version label to modify the version bump.
  • If the bot has failed to detect any changes, or if this pull request needs to update multiple packages to different versions or requires a more comprehensive changelog entry, maintainers can update the changelog file directly.

@@ -1029,8 +1028,6 @@ def _get_component_type(self, component_id: int):
)

def _get_parameters_info(self) -> list[ParameterInfo] | None:
if not self.client._info:
self._info = self.client._get_api_info()
Copy link
Member

Choose a reason for hiding this comment

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

Whoops 😭

Copy link
Member

@abidlabs abidlabs left a comment

Choose a reason for hiding this comment

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

LGTM thanks for fixing this @freddyaboulton!

@freddyaboulton
Copy link
Collaborator Author

Thank you for the quick review!! And @pseudotensor for the tip about the test

@freddyaboulton freddyaboulton merged commit 946487c into main Mar 29, 2024
7 checks passed
@freddyaboulton freddyaboulton deleted the 7882-cache-api-info-only-call-once-in-client branch March 29, 2024 17:17
@pngwn pngwn mentioned this pull request Mar 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v: patch A change that requires a patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[REGRESSION] client hangs reaching server on 4.23.0 and 4.24.0 (ok for 4.22.0 and lower) -- with repro
3 participants