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

Gradio APIs breaks calling private endpoints on HF #6430

Closed
1 task done
fffiloni opened this issue Nov 15, 2023 · 1 comment · Fixed by #6602
Closed
1 task done

Gradio APIs breaks calling private endpoints on HF #6430

fffiloni opened this issue Nov 15, 2023 · 1 comment · Fixed by #6602
Labels
bug Something isn't working Regression Bugs did not exist in previous versions of Gradio

Comments

@fffiloni
Copy link

Describe the bug

I think i found the reason for bugs while calling gradio APIs:

Here you can try several examples : https://huggingface.co/spaces/fffiloni/calling-gradio-api-tests
The demo is calling endpoints from this one : https://huggingface.co/spaces/fffiloni/gradio-api-tests [which is PRIVATE]

Everything works fine if the endpoints space is PUBLIC, otherwise everything breaks if the endpoints space is PRIVATE
GRADIO VERSION: 4.3.0

Have you searched existing issues? 🔎

  • I have searched and found no existing issues

Reproduction

Here you can try several examples : https://huggingface.co/spaces/fffiloni/calling-gradio-api-tests

Screenshot

No response

Logs

Traceback (most recent call last):
  File "/home/user/.local/lib/python3.10/site-packages/gradio/queueing.py", line 427, in call_prediction
    output = await route_utils.call_process_api(
  File "/home/user/.local/lib/python3.10/site-packages/gradio/route_utils.py", line 232, in call_process_api
    output = await app.get_blocks().process_api(
  File "/home/user/.local/lib/python3.10/site-packages/gradio/blocks.py", line 1525, in process_api
    result = await self.call_function(
  File "/home/user/.local/lib/python3.10/site-packages/gradio/blocks.py", line 1147, in call_function
    prediction = await anyio.to_thread.run_sync(
  File "/home/user/.local/lib/python3.10/site-packages/anyio/to_thread.py", line 33, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
  File "/home/user/.local/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 877, in run_sync_in_worker_thread
    return await future
  File "/home/user/.local/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 807, in run
    result = context.run(func, *args)
  File "/home/user/.local/lib/python3.10/site-packages/gradio/utils.py", line 672, in wrapper
    response = f(*args, **kwargs)
  File "/home/user/app/app.py", line 17, in api_t2i
    result = client.predict(
  File "/home/user/.local/lib/python3.10/site-packages/gradio_client/client.py", line 305, in predict
    return self.submit(*args, api_name=api_name, fn_index=fn_index).result()
  File "/home/user/.local/lib/python3.10/site-packages/gradio_client/client.py", line 1456, in result
    return super().result(timeout=timeout)
  File "/usr/local/lib/python3.10/concurrent/futures/_base.py", line 458, in result
    return self.__get_result()
  File "/usr/local/lib/python3.10/concurrent/futures/_base.py", line 403, in __get_result
    raise self._exception
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/user/.local/lib/python3.10/site-packages/gradio_client/client.py", line 869, in _inner
    predictions = _predict(*data)
  File "/home/user/.local/lib/python3.10/site-packages/gradio_client/client.py", line 894, in _predict
    result = utils.synchronize_async(self._sse_fn, data, hash_data, helper)
  File "/home/user/.local/lib/python3.10/site-packages/gradio_client/utils.py", line 664, in synchronize_async
    return fsspec.asyn.sync(fsspec.asyn.get_loop(), func, *args, **kwargs)  # type: ignore
  File "/home/user/.local/lib/python3.10/site-packages/fsspec/asyn.py", line 103, in sync
    raise return_result
  File "/home/user/.local/lib/python3.10/site-packages/fsspec/asyn.py", line 56, in _runner
    result[0] = await coro
  File "/home/user/.local/lib/python3.10/site-packages/gradio_client/client.py", line 1075, in _sse_fn
    return await utils.get_pred_from_sse(
  File "/home/user/.local/lib/python3.10/site-packages/gradio_client/utils.py", line 341, in get_pred_from_sse
    return task.result()
  File "/home/user/.local/lib/python3.10/site-packages/gradio_client/utils.py", line 410, in stream_sse
    raise ValueError(f"Unexpected message: {line}")
ValueError: Unexpected message: <!DOCTYPE html>
<html class="">
<head>
    <meta charset="utf-8"/>
    <meta
            name="viewport"
            content="width=device-width, initial-scale=1.0, user-scalable=no"
    />
    <meta
            name="description"
            content="We're on a journey to advance and democratize artificial intelligence through open source and open science."
    />
    <meta property="fb:app_id" content="1321688464574422"/>
    <meta name="twitter:card" content="summary_large_image"/>
    <meta name="twitter:site" content="@huggingface"/>
    <meta
            property="og:title"
            content="Hugging Face – The AI community building the future."
    />
    <meta property="og:type" content="website"/>

    <title>Hugging Face – The AI community building the future.</title>
    <style>
        body {
            margin: 0;
        }

        main {
            background-color: white;
            min-height: 100vh;
            padding: 7rem 1rem 8rem 1rem;
            text-align: center;
            font-family: Source Sans Pro, ui-sans-serif, system-ui, -apple-system,
            BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans,
            sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol,
            Noto Color Emoji;
        }

        img {
            width: 6rem;
            height: 6rem;
            margin: 0 auto 1rem;
        }

        h1 {
            font-size: 3.75rem;
            line-height: 1;
            color: rgba(31, 41, 55, 1);
            font-weight: 700;
            box-sizing: border-box;
            margin: 0 auto;
        }

        p {
            color: rgba(107, 114, 128, 1);
            font-size: 1.125rem;
            line-height: 1.75rem;
            max-width: 28rem;
            box-sizing: border-box;
            margin: 0 auto;
        }

        .dark main {
            background-color: rgb(11, 15, 25);
        }

        .dark h1 {
            color: rgb(209, 213, 219);
        }

        .dark p {
            color: rgb(156, 163, 175);
        }
    </style>
    <script>
        // On page load or when changing themes, best to add inline in `head` to avoid FOUC
        const key = "_tb_global_settings";
        let theme = window.matchMedia("(prefers-color-scheme: dark)").matches
            ? "dark"
            : "light";
        try {
            const storageTheme = JSON.parse(window.localStorage.getItem(key)).theme;
            if (storageTheme) {
                theme = storageTheme === "dark" ? "dark" : "light";
            }
        } catch (e) {
        }
        if (theme === "dark") {
            document.documentElement.classList.add("dark");
        } else {
            document.documentElement.classList.remove("dark");
        }
    </script>
</head>

<body>
<main>
    <img
            src="https://huggingface.co/front/assets/huggingface_logo.svg"
            alt=""
    />
    <div>
        <h1>404</h1>
        <p>Sorry, we can't find the page you are looking for.</p>
    </div>
</main>
</body>
</html>


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/user/.local/lib/python3.10/site-packages/gradio/queueing.py", line 472, in process_events
    response = await self.call_prediction(awake_events, batch)
  File "/home/user/.local/lib/python3.10/site-packages/gradio/queueing.py", line 436, in call_prediction
    raise Exception(str(error) if show_error else None) from error
Exception: None

System Info

HuggingFace hub
Gradio version 4.3.0

Severity

Blocking usage of gradio

@fffiloni fffiloni added the bug Something isn't working label Nov 15, 2023
@abidlabs abidlabs added the Regression Bugs did not exist in previous versions of Gradio label Nov 15, 2023
@fffiloni
Copy link
Author

fffiloni commented Nov 16, 2023

I think this issue may be related to #6388 ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Regression Bugs did not exist in previous versions of Gradio
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants