Skip to content

Commit

Permalink
Fix gr.load() so that it works with the SSE v1 protocol (#6810)
Browse files Browse the repository at this point in the history
* fix for gr.load()

* add changeset

* fix

* add test

* add changeset

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
  • Loading branch information
abidlabs and gradio-pr-bot committed Dec 15, 2023
1 parent 6b130e2 commit 526fb6c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/shy-pots-stare.md
@@ -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
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)
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
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

0 comments on commit 526fb6c

Please sign in to comment.