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

Private space with python client API returning 404 #6388

Closed
1 task done
muhammadumair894 opened this issue Nov 12, 2023 · 3 comments · Fixed by #6602
Closed
1 task done

Private space with python client API returning 404 #6388

muhammadumair894 opened this issue Nov 12, 2023 · 3 comments · Fixed by #6602
Assignees
Labels
bug Something isn't working Regression Bugs did not exist in previous versions of Gradio

Comments

@muhammadumair894
Copy link

Describe the bug

I have created a sample private gradio space, and called it with HF token, but got an error in response, meanwhile works fine if the change space visibility to public.
Need help to resolve this issue. Thanks in advance.

from gradio_client import Client

client = Client("https://gic-qa.hf.space/--replicas/qfd/", hf_token="hf_umXwOeMSkURPBTFWD....")
result = client.predict("my name is abc ",3999,api_name="/predict")	

print(result)

Error

[/usr/local/lib/python3.10/dist-packages/gradio_client/utils.py](https://localhost:8080/#) in stream_sse(client, data, hash_data, helper, sse_url, sse_data_url, cookies)
    408                         return resp["output"]
    409                 else:
--> 410                     raise ValueError(f"Unexpected message: {line}")
    411         raise ValueError("Did not receive process_completed message.")
    412     except asyncio.CancelledError:

ValueError: Unexpected message:

Have you searched existing issues? 🔎

  • I have searched and found no existing issues

Reproduction

import gradio as gr

def process_input(text, number):

  | # You can perform any processing or computation here
  | # For simplicity, this example just combines the inputs into a dictionary
  | result = {'input_text': text, 'input_number': number}
  | return result
  |  
  | iface = gr.Interface(
  | fn=process_input,
  | inputs=["text", "number"],
  | outputs="json"
  | )
  |  
  | iface.launch()

Screenshot

No response

Logs

Loaded as API: https://orblogic-qa-ui-api.hf.space/--replicas/qfm9d/ ✔
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-24-270722ffafe2> in <cell line: 4>()
      2 
      3 client = Client("https://orblogic-qa-ui-api.hf.space/--replicas/qfm9d/", hf_token="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")
----> 4 result = client.predict("my name is khan ",3999,api_name="/predict")
      5 
      6 print(result)

12 frames
/usr/local/lib/python3.10/dist-packages/gradio_client/client.py in predict(self, api_name, fn_index, *args)
    303                 "Cannot call predict on this function as it may run forever. Use submit instead."
    304             )
--> 305         return self.submit(*args, api_name=api_name, fn_index=fn_index).result()
    306 
    307     def new_helper(self, fn_index: int) -> Communicator:

/usr/local/lib/python3.10/dist-packages/gradio_client/client.py in result(self, timeout)
   1454             >> 9
   1455         """
-> 1456         return super().result(timeout=timeout)
   1457 
   1458     def outputs(self) -> list[tuple | Any]:

/usr/lib/python3.10/concurrent/futures/_base.py in result(self, timeout)
    456                     raise CancelledError()
    457                 elif self._state == FINISHED:
--> 458                     return self.__get_result()
    459                 else:
    460                     raise TimeoutError()

/usr/lib/python3.10/concurrent/futures/_base.py in __get_result(self)
    401         if self._exception:
    402             try:
--> 403                 raise self._exception
    404             finally:
    405                 # Break a reference cycle with the exception in self._exception

/usr/lib/python3.10/concurrent/futures/thread.py in run(self)
     56 
     57         try:
---> 58             result = self.fn(*self.args, **self.kwargs)
     59         except BaseException as exc:
     60             self.future.set_exception(exc)

/usr/local/lib/python3.10/dist-packages/gradio_client/client.py in _inner(*data)
    867             if self.client.serialize:
    868                 data = self.serialize(*data)
--> 869             predictions = _predict(*data)
    870             predictions = self.process_predictions(*predictions)
    871             # Append final output only if not already present

/usr/local/lib/python3.10/dist-packages/gradio_client/client.py in _predict(*data)
    892             }
    893 
--> 894             result = utils.synchronize_async(self._sse_fn, data, hash_data, helper)
    895             if "error" in result:
    896                 raise ValueError(result["error"])

/usr/local/lib/python3.10/dist-packages/gradio_client/utils.py in synchronize_async(func, *args, **kwargs)
    662         **kwargs:
    663     """
--> 664     return fsspec.asyn.sync(fsspec.asyn.get_loop(), func, *args, **kwargs)  # type: ignore
    665 
    666 

/usr/local/lib/python3.10/dist-packages/fsspec/asyn.py in sync(loop, func, timeout, *args, **kwargs)
    104         raise FSTimeoutError from return_result
    105     elif isinstance(return_result, BaseException):
--> 106         raise return_result
    107     else:
    108         return return_result

/usr/local/lib/python3.10/dist-packages/fsspec/asyn.py in _runner(event, coro, result, timeout)
     59         coro = asyncio.wait_for(coro, timeout=timeout)
     60     try:
---> 61         result[0] = await coro
     62     except Exception as ex:
     63         result[0] = ex

/usr/local/lib/python3.10/dist-packages/gradio_client/client.py in _sse_fn(self, data, hash_data, helper)
   1073     async def _sse_fn(self, data: dict, hash_data: dict, helper: Communicator):
   1074         async with httpx.AsyncClient(timeout=httpx.Timeout(timeout=None)) as client:
-> 1075             return await utils.get_pred_from_sse(
   1076                 client,
   1077                 data,

/usr/local/lib/python3.10/dist-packages/gradio_client/utils.py in get_pred_from_sse(client, data, hash_data, helper, sse_url, sse_data_url, cookies)
    339     assert len(done) == 1
    340     for task in done:
--> 341         return task.result()
    342 
    343 

/usr/local/lib/python3.10/dist-packages/gradio_client/utils.py in stream_sse(client, data, hash_data, helper, sse_url, sse_data_url, cookies)
    408                         return resp["output"]
    409                 else:
--> 410                     raise ValueError(f"Unexpected message: {line}")
    411         raise ValueError("Did not receive process_completed message.")
    412     except asyncio.CancelledError:

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>

System Info

HF Spaces

Severity

Blocking usage of gradio

@muhammadumair894 muhammadumair894 added the bug Something isn't working label Nov 12, 2023
@abidlabs abidlabs added the Regression Bugs did not exist in previous versions of Gradio label Nov 13, 2023
@abidlabs abidlabs self-assigned this Nov 13, 2023
@freddyaboulton
Copy link
Collaborator

And your token has proper permissions to access the gic organization ? https://huggingface.co/GICPrivateLimited

@dwipper
Copy link

dwipper commented Nov 14, 2023

@freddyaboulton @abidlabs I'm having a similar issue with this public (https://huggingface.co/spaces/cimsai/Compliance?logs=container) Space that calls a private space. When I click the "Upload Contract" (which is running in the private space), it throws the error. Versions are both 4.3.0

`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/.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:

<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>

404

Sorry, we can’t find the page you are looking for.

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`

@muhammadumair894
Copy link
Author

And your token has proper permissions to access the gic organization ? https://huggingface.co/GICPrivateLimited

I've attempted to use both read and write permissions, but it's still not working.

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.

4 participants