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

Initialize the client with the fake host for Lite server #8935

Merged
merged 3 commits into from
Aug 14, 2024

Conversation

whitphx
Copy link
Member

@whitphx whitphx commented Jul 30, 2024

Description

Lite apps hosted on HF Spaces show the following error during the initialization while the app will be successfully launched finally.
CleanShot 2024-07-30 at 14 59 21@2x

This PR fixes it.

@gradio-pr-bot
Copy link
Collaborator

gradio-pr-bot commented Jul 30, 2024

🪼 branch checks and previews

Name Status URL
Spaces ready! Spaces preview
Website building...
Storybook ready! Storybook preview
🦄 Changes detected! Details

Install Gradio from this PR

pip install https://gradio-pypi-previews.s3.amazonaws.com/80d91dc036fafed80a45bf2abcea965b3de3f707/gradio-4.40.0-py3-none-any.whl

Install Gradio Python Client from this PR

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

Install Gradio JS Client from this PR

npm install https://gradio-npm-previews.s3.amazonaws.com/80d91dc036fafed80a45bf2abcea965b3de3f707/gradio-client-1.4.0.tgz

@gradio-pr-bot
Copy link
Collaborator

gradio-pr-bot commented Jul 30, 2024

🦄 change detected

This Pull Request includes changes to the following packages.

Package Version
@gradio/app minor
@gradio/wasm minor
gradio minor
  • Maintainers can select this checkbox to manually select packages to update.

With the following changelog entry.

Initialize the client with the fake host for Lite server

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.

@@ -181,7 +182,7 @@
<Index
space={null}
src={null}
host={null}
host={FAKE_LITE_HOST}
Copy link
Member Author

Choose a reason for hiding this comment

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

This host is passed to the client object through the code below

api_url =
BUILD_MODE === "dev" || gradio_dev_mode === "dev"
? `http://localhost:${
typeof server_port === "number" ? server_port : 7860
}`
: host || space || src || location.origin;
app = await Client.connect(api_url, {
status_callback: handle_status,
with_null_state: true,
events: ["data", "log", "status", "render"]
});

and the client makes an HTTP call if the URL matches HF Spaces' host here, which causes the error:

const { http_protocol, host, space_id } = await process_endpoint(
this.app_reference,
this.options.hf_token
);

So we explicitly set the different value to host, which is also considered as a special host name representing the Lite's server.

Copy link
Member Author

Choose a reason for hiding this comment

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

@pngwn Should we use src rather than host? #3065

Copy link
Member

Choose a reason for hiding this comment

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

That is a breaking change, so it will need to happen in 5.0.

Copy link
Member Author

Choose a reason for hiding this comment

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

@pngwn Thanks but do you mean we need to wait for this to be merged until 5.0, or just using host not src is ok and we can merge this?

Copy link
Member Author

Choose a reason for hiding this comment

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

Should be merged after #9102?

Copy link
Member

@pngwn pngwn left a comment

Choose a reason for hiding this comment

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

Looks great. Thanks @whitphx!

@whitphx whitphx merged commit f6b2b97 into main Aug 14, 2024
19 checks passed
@whitphx whitphx deleted the set-fake-lite-host branch August 14, 2024 06:50
This was referenced Aug 13, 2024
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