-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Conversation
🪼 branch checks and previews
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 |
🦄 change detectedThis Pull Request includes changes to the following packages.
With the following changelog entry.
Maintainers or the PR author can modify the PR title to modify this entry.
|
@@ -181,7 +182,7 @@ | |||
<Index | |||
space={null} | |||
src={null} | |||
host={null} | |||
host={FAKE_LITE_HOST} |
There was a problem hiding this comment.
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
gradio/js/app/src/Index.svelte
Lines 276 to 287 in 9b42ba8
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:
gradio/client/js/src/client.ts
Lines 235 to 238 in 9b42ba8
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this 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!
Description
Lite apps hosted on HF Spaces show the following error during the initialization while the app will be successfully launched finally.
This PR fixes it.