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 gr.load() so that it works with the SSE v1 protocol #6810

Merged
merged 6 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/shy-pots-stare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"gradio": patch
---

fix:Fix `gr.load()` so that it works with the SSE v1 protocol
4 changes: 1 addition & 3 deletions gradio/external.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,9 +538,7 @@ def from_spaces_blocks(space: str, hf_token: str | None) -> Blocks:
predict_fns = []
for fn_index, endpoint in enumerate(client.endpoints):
assert isinstance(endpoint, Endpoint)
helper = None
if endpoint.protocol in ("ws", "sse"):
helper = client.new_helper(fn_index)
helper = client.new_helper(fn_index)
Copy link
Member Author

Choose a reason for hiding this comment

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

Initially I had added "sse_v1" to the list but actually I don't think there's any reason to have this check because gr.load() only works with gradio==4.x which includes the protocol anymore

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this makes sense

predict_fns.append(endpoint.make_end_to_end_fn(helper))
return gradio.Blocks.from_config(client.config, predict_fns, client.src)

Expand Down
12 changes: 12 additions & 0 deletions test/test_external.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,18 @@ def test_loading_files_via_proxy_works(self):
)
assert r.status_code == 200

def test_private_space_v4_sse_v1(self):
io = gr.load(
"spaces/gradio-tests/not-actually-private-spacev4-sse-v1",
hf_token=HfFolder.get_token(),
)
try:
output = io("abc")
assert output == "abc"
assert io.theme.name == "gradio/monochrome"
except TooManyRequestsError:
pass


class TestLoadInterfaceWithExamples:
def test_interface_load_examples(self, tmp_path):
Expand Down
Loading