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

gr.load() failing with Error #5927

Closed
amitagh opened this issue Oct 16, 2023 · 23 comments · Fixed by #6602 or #6810
Closed

gr.load() failing with Error #5927

amitagh opened this issue Oct 16, 2023 · 23 comments · Fixed by #6602 or #6810
Labels
bug Something isn't working Regression Bugs did not exist in previous versions of Gradio

Comments

@amitagh
Copy link

amitagh commented Oct 16, 2023

Describe the bug

I am trying load a pvt space from a public space.
below is code for public space:
demo = gr.load(name="spaces/amitagh/TestChatIntf", hf_token = MY_HF_TOKEN_KEY)
demo.launch()


pvt space amitagh/TestChatIntf has just following simple code:
import gradio as gr

def echo(message, history):
return message

demo = gr.ChatInterface(fn=echo, examples=["hello", "hola", "merhaba"], title="Echo Bot")
demo.launch()

Getting below error:
Fetching Space from: https://huggingface.co/spaces/amitagh/TestChatIntf
Loaded as API: https://amitagh-testchatintf.hf.space
/home/user/app/app.py:9: GradioUnusedKwargWarning: You have unused kwarg parameters in Chatbot, please remove them: {'likeable': False}
demo = gr.load(name="spaces/amitagh/TestChatIntf", hf_token = hf_key, api_key = hf_key)
Traceback (most recent call last):
File "/home/user/app/app.py", line 9, in
demo = gr.load(name="spaces/amitagh/TestChatIntf", hf_token = hf_key, api_key = hf_key)
File "/home/user/.local/lib/python3.10/site-packages/gradio/external.py", line 70, in load
return load_blocks_from_repo(
File "/home/user/.local/lib/python3.10/site-packages/gradio/external.py", line 109, in load_blocks_from_repo
blocks: gradio.Blocks = factory_methods[src](name, hf_token, alias, **kwargs)
File "/home/user/.local/lib/python3.10/site-packages/gradio/external.py", line 504, in from_spaces
return from_spaces_blocks(space=space_name, hf_token=hf_token)
File "/home/user/.local/lib/python3.10/site-packages/gradio/external.py", line 510, in from_spaces_blocks
return gradio.Blocks.from_config(client.config, predict_fns, client.src)
File "/home/user/.local/lib/python3.10/site-packages/gradio/blocks.py", line 801, in from_config
targets = [
File "/home/user/.local/lib/python3.10/site-packages/gradio/blocks.py", line 803, in
original_mapping[
KeyError: None

@amitagh amitagh added the bug Something isn't working label Oct 16, 2023
@amitagh amitagh changed the title hf_token env variable issue and then gr.load() failing with Error non gr.load() failing with Error Oct 16, 2023
@abidlabs
Copy link
Member

Hi @amitagh can you confirm both Spaces are running the latest version of Gradio? The Gradio version is set by the the sdk_version in the README file

@amitagh
Copy link
Author

amitagh commented Oct 17, 2023 via email

@amitagh
Copy link
Author

amitagh commented Oct 17, 2023

Below is what i see in Public space.
sdk: gradio
sdk_version: 3.47.1
Below is what i see in Public space.
sdk: gradio
sdk_version: 3.47.1

So pretty much same.

@amitagh
Copy link
Author

amitagh commented Oct 17, 2023

This issue seems to be with Gradio ChatInterface object.
It works fine with Gradio Interface object.

@dwipper
Copy link

dwipper commented Nov 1, 2023

I have the same problem when calling a private space app from a public space app. The private space app is using Blocks (not Interface or ChatInterface):

with (gr.Blocks(CIMStheme) as iface):
    with gr.Row():
[a bunch of components and buttons here]

iface.load(get_username,inputs=username_tbox,outputs=username_tbox)
iface.launch()

If I comment the 'load' line out, the public space loads fine, otherwise I get this error message in the public space app:

Fetching Space from: https://huggingface.co/spaces/dwipper/NILI-Mobile
Loaded as API: https://dwipper-nili-mobile.hf.space ✔
Traceback (most recent call last):
  File "/home/user/app/app.py", line 89, in <module>
    nili = gr.load(src="spaces",name="dwipper/NILI-Mobile",hf_token=HUGGING_FACE_TOKEN)
  File "/home/user/.local/lib/python3.10/site-packages/gradio/external.py", line 70, in load
    return load_blocks_from_repo(
  File "/home/user/.local/lib/python3.10/site-packages/gradio/external.py", line 109, in load_blocks_from_repo
    blocks: gradio.Blocks = factory_methods[src](name, hf_token, alias, **kwargs)
  File "/home/user/.local/lib/python3.10/site-packages/gradio/external.py", line 505, in from_spaces
    return from_spaces_blocks(space=space_name, hf_token=hf_token)
  File "/home/user/.local/lib/python3.10/site-packages/gradio/external.py", line 511, in from_spaces_blocks
    return gradio.Blocks.from_config(client.config, predict_fns, client.src)
  File "/home/user/.local/lib/python3.10/site-packages/gradio/blocks.py", line 793, in from_config
    targets = [
  File "/home/user/.local/lib/python3.10/site-packages/gradio/blocks.py", line 795, in <listcomp>
    original_mapping[
KeyError: None

@dwipper
Copy link

dwipper commented Nov 3, 2023

@abidlabs

I made multiple tries at this. While the .load works fine when the auth login is in the same Space, but using the API to load from a private space still throws and error. I'm wondering if there is another undocumented param that needs to be passed?

nili = gr.load(src="spaces",name="dwipper/NILI-Mobile",hf_token=HUGGING_FACE_TOKEN)
nili.launch(auth=login_auth, auth_message= "Enter your username and password that you received from CIMS.AI. To request a login, please email 'info@cims.ai'")

Fetching Space from: https://huggingface.co/spaces/dwipper/NILI-Mobile
Loaded as API: https://dwipper-nili-mobile.hf.space ✔
Traceback (most recent call last):
  File "/home/user/app/app.py", line 93, in <module>
    nili = gr.load(src="spaces",name="dwipper/NILI-Mobile",hf_token=HUGGING_FACE_TOKEN)
  File "/home/user/.local/lib/python3.10/site-packages/gradio/external.py", line 70, in load
    return load_blocks_from_repo(
  File "/home/user/.local/lib/python3.10/site-packages/gradio/external.py", line 109, in load_blocks_from_repo
    blocks: gradio.Blocks = factory_methods[src](name, hf_token, alias, **kwargs)
  File "/home/user/.local/lib/python3.10/site-packages/gradio/external.py", line 505, in from_spaces
    return from_spaces_blocks(space=space_name, hf_token=hf_token)
  File "/home/user/.local/lib/python3.10/site-packages/gradio/external.py", line 511, in from_spaces_blocks
    return gradio.Blocks.from_config(client.config, predict_fns, client.src)
  File "/home/user/.local/lib/python3.10/site-packages/gradio/blocks.py", line 793, in from_config
    targets = [
  File "/home/user/.local/lib/python3.10/site-packages/gradio/blocks.py", line 795, in <listcomp>
    original_mapping[
KeyError: None

I tried a couple combinations of the load statement in the private Spaces code. All generated the above error when restarting the public space:

  • gr.Blocks.load(iface,fn=set_defaults)
  • iface.load(fn=set_defaults)

@dwipper
Copy link

dwipper commented Nov 6, 2023

This issue seems to be resolved in 4.1.1

@ACOLLINS2
Copy link

I am having the same issue.

.load works fine when I make my source space a public space, but when I change it to a private space I get an error.

Interestingly, the space is successfully fetched and loaded, however when you interface with it, it usually has a thing, tries to send back an output and then simply produces an error message in the place of the output.

Like I said, it works fine when the source space is made public.
Both of my spaces are running Gradio 4.1.1

@dwipper
Copy link

dwipper commented Nov 6, 2023

@ACOLLINS2 Might be a good point. I made both spaces public so that Support could see them, but originally, had a public/private mix when I had the error. I'll flip it back to see if it still works.

@ACOLLINS2
Copy link

@dwipper I've just managed to get mine to work again using a temporary fix.

Temporary solution: I rolled back my gradio SDK version in HF Spaces to use 3.45.0

@dwipper
Copy link

dwipper commented Nov 12, 2023

@abidlabs This Space https://huggingface.co/spaces/cimsai/NILI-Mobile-New calls this Space: https://huggingface.co/spaces/dwipper/NILI-Mobile-Simple . Both are 4.2.0.

When these two spaces are public, the .load in NILI-Mobile-Simple works fine. But when the NILI-Mobile-Simple is made private, the NILI-Mobile-New Space throws this error (which is different than the above error):

`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 234, in call_process_api
output = await app.get_blocks().process_api(
File "/home/user/.local/lib/python3.10/site-packages/gradio/blocks.py", line 1487, in process_api
result = await self.call_function(
File "/home/user/.local/lib/python3.10/site-packages/gradio/blocks.py", line 1109, 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 665, 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.

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 234, in call_process_api
output = await app.get_blocks().process_api(
File "/home/user/.local/lib/python3.10/site-packages/gradio/blocks.py", line 1487, in process_api
result = await self.call_function(
File "/home/user/.local/lib/python3.10/site-packages/gradio/blocks.py", line 1109, 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 665, 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`

@abidlabs abidlabs added the Regression Bugs did not exist in previous versions of Gradio label Nov 20, 2023
@dwipper
Copy link

dwipper commented Nov 20, 2023

May be related to this issue: #6476

@ACOLLINS2
Copy link

I believe that this issue is still open. My Spaces won't communicate to each other via gr.load and throws up the error below.

The spaces in question (both made public for this test):
https://huggingface.co/spaces/PharmaAI/private_gradio_test
https://huggingface.co/spaces/PharmaAI/open_gradio_test

Both use Gradio Version 4.9.1

The error produced by open_gradio_test when loading (and interacting with) private_gradio_test:

Traceback (most recent call last):
File "/home/user/.local/lib/python3.10/site-packages/gradio/queueing.py", line 459, 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 1533, in process_api
result = await self.call_function(
File "/home/user/.local/lib/python3.10/site-packages/gradio/blocks.py", line 1151, 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 678, in wrapper
response = f(*args, **kwargs)
File "/home/user/.local/lib/python3.10/site-packages/gradio_client/client.py", line 959, in _inner
predictions = _predict(*data)
File "/home/user/.local/lib/python3.10/site-packages/gradio_client/client.py", line 994, in _predict
result = utils.synchronize_async(self._sse_fn_v1, helper, event_id)
File "/home/user/.local/lib/python3.10/site-packages/gradio_client/utils.py", line 808, 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 1188, in _sse_fn_v1
return await utils.get_pred_from_sse_v1(
File "/home/user/.local/lib/python3.10/site-packages/gradio_client/utils.py", line 412, in get_pred_from_sse_v1
assert len(done) == 1
AssertionError
Traceback (most recent call last):
File "/home/user/.local/lib/python3.10/site-packages/gradio/queueing.py", line 459, 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 1533, in process_api
result = await self.call_function(
File "/home/user/.local/lib/python3.10/site-packages/gradio/blocks.py", line 1151, 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 678, in wrapper
response = f(*args, **kwargs)
File "/home/user/.local/lib/python3.10/site-packages/gradio_client/client.py", line 959, in _inner
predictions = _predict(*data)
File "/home/user/.local/lib/python3.10/site-packages/gradio_client/client.py", line 994, in _predict
result = utils.synchronize_async(self._sse_fn_v1, helper, event_id)
File "/home/user/.local/lib/python3.10/site-packages/gradio_client/utils.py", line 808, 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 1188, in _sse_fn_v1
return await utils.get_pred_from_sse_v1(
File "/home/user/.local/lib/python3.10/site-packages/gradio_client/utils.py", line 412, in get_pred_from_sse_v1
assert len(done) == 1
AssertionError

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 497, in process_events
response = await self.call_prediction(awake_events, batch)
File "/home/user/.local/lib/python3.10/site-packages/gradio/queueing.py", line 468, in call_prediction
raise Exception(str(error) if show_error else None) from error
Exception: None
Task exception was never retrieved
future: <Task finished name='Task-87' coro=<check_for_cancel() done, defined at /home/user/.local/lib/python3.10/site-packages/gradio_client/utils.py:417> exception=AttributeError("'NoneType' object has no attribute 'lock'")>
Traceback (most recent call last):
File "/home/user/.local/lib/python3.10/site-packages/gradio_client/utils.py", line 422, in check_for_cancel
with helper.lock:
AttributeError: 'NoneType' object has no attribute 'lock'
Task exception was never retrieved
future: <Task finished name='Task-88' coro=<stream_sse_v1() done, defined at /home/user/.local/lib/python3.10/site-packages/gradio_client/utils.py:505> exception=AttributeError("'NoneType' object has no attribute 'lock'")>
Traceback (most recent call last):
File "/home/user/.local/lib/python3.10/site-packages/gradio_client/utils.py", line 523, in stream_sse_v1
with helper.lock:
AttributeError: 'NoneType' object has no attribute 'lock'
Traceback (most recent call last):
File "/home/user/.local/lib/python3.10/site-packages/gradio/routes.py", line 568, in predict
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 1533, in process_api
result = await self.call_function(
File "/home/user/.local/lib/python3.10/site-packages/gradio/blocks.py", line 1151, 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 678, in wrapper
response = f(*args, **kwargs)
File "/home/user/.local/lib/python3.10/site-packages/gradio_client/client.py", line 955, in _inner
raise utils.InvalidAPIEndpointError()
gradio_client.utils.InvalidAPIEndpointError
Traceback (most recent call last):
File "/home/user/.local/lib/python3.10/site-packages/gradio/routes.py", line 568, in predict
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 1533, in process_api
result = await self.call_function(
File "/home/user/.local/lib/python3.10/site-packages/gradio/blocks.py", line 1151, 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 678, in wrapper
response = f(*args, **kwargs)
File "/home/user/.local/lib/python3.10/site-packages/gradio_client/client.py", line 955, in _inner
raise utils.InvalidAPIEndpointError()
gradio_client.utils.InvalidAPIEndpointError

@abidlabs
Copy link
Member

I can confirm that this is not working on 4.9.1. Although I'm getting a slightly different error:

Traceback (most recent call last):
  File "/home/user/.local/lib/python3.10/site-packages/gradio/queueing.py", line 497, in process_events
    response = await self.call_prediction(awake_events, batch)
  File "/home/user/.local/lib/python3.10/site-packages/gradio/queueing.py", line 468, in call_prediction
    raise Exception(str(error) if show_error else None) from error
Exception: None
Traceback (most recent call last):
  File "/home/user/.local/lib/python3.10/site-packages/gradio/queueing.py", line 459, 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 1533, in process_api
    result = await self.call_function(
  File "/home/user/.local/lib/python3.10/site-packages/gradio/blocks.py", line 1151, 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 678, in wrapper
    response = f(*args, **kwargs)
  File "/home/user/.local/lib/python3.10/site-packages/gradio_client/client.py", line 959, in _inner
    predictions = _predict(*data)
  File "/home/user/.local/lib/python3.10/site-packages/gradio_client/client.py", line 994, in _predict
    result = utils.synchronize_async(self._sse_fn_v1, helper, event_id)
  File "/home/user/.local/lib/python3.10/site-packages/gradio_client/utils.py", line 808, 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 1188, in _sse_fn_v1
    return await utils.get_pred_from_sse_v1(
  File "/home/user/.local/lib/python3.10/site-packages/gradio_client/utils.py", line 414, in get_pred_from_sse_v1
    return task.result()
  File "/home/user/.local/lib/python3.10/site-packages/gradio_client/utils.py", line 422, in check_for_cancel
    with helper.lock:
AttributeError: 'NoneType' object has no attribute 'lock'
Traceback (most recent call last):
  File "/home/user/.local/lib/python3.10/site-packages/gradio/queueing.py", line 459, 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 1533, in process_api
    result = await self.call_function(
  File "/home/user/.local/lib/python3.10/site-packages/gradio/blocks.py", line 1151, 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 678, in wrapper
    response = f(*args, **kwargs)
  File "/home/user/.local/lib/python3.10/site-packages/gradio_client/client.py", line 959, in _inner
    predictions = _predict(*data)
  File "/home/user/.local/lib/python3.10/site-packages/gradio_client/client.py", line 994, in _predict
    result = utils.synchronize_async(self._sse_fn_v1, helper, event_id)
  File "/home/user/.local/lib/python3.10/site-packages/gradio_client/utils.py", line 808, 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 1188, in _sse_fn_v1
    return await utils.get_pred_from_sse_v1(
  File "/home/user/.local/lib/python3.10/site-packages/gradio_client/utils.py", line 414, in get_pred_from_sse_v1
    return task.result()
  File "/home/user/.local/lib/python3.10/site-packages/gradio_client/utils.py", line 422, in check_for_cancel
    with helper.lock:
AttributeError: 'NoneType' object has no attribute 'lock'

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 497, in process_events
    response = await self.call_prediction(awake_events, batch)
  File "/home/user/.local/lib/python3.10/site-packages/gradio/queueing.py", line 468, in call_prediction
    raise Exception(str(error) if show_error else None) from error
Exception: None

@abidlabs abidlabs reopened this Dec 15, 2023
@abidlabs
Copy link
Member

Actually I think the problem is not just restricted to private Spaces -- even public Spaces are failing for me, such as yours:

import gradio as gr

gr.load("spaces/PharmaAI/private_gradio_test").launch()

@freddyaboulton
Copy link
Collaborator

freddyaboulton commented Dec 15, 2023

I can't repro with the the `PharmaAI/private_gradio_test" on 4.9.1 . Just FYI.

image

EDIT - never mind I get the same error when I submit a prediction! I thought it was just loading the app that was broken

@abidlabs
Copy link
Member

Weird I see the issue (and am about to open a PR with the fix)

@dwipper
Copy link

dwipper commented Dec 15, 2023

I get errors between these two public spaces:

https://huggingface.co/spaces/cimsai/Compliance
https://huggingface.co/spaces/dwipper/Compliance_Test

login: admin / admin

In the backend space, the login works fine. In the front end space, it throws this error message:

Fetching Space from: https://huggingface.co/spaces/dwipper/Compliance_Test
Loaded as API: https://dwipper-compliance-test.hf.space
Running on local URL: http://0.0.0.0:7860

To create a public link, set share=True in launch().
Traceback (most recent call last):
File "/home/user/.local/lib/python3.10/site-packages/gradio/queueing.py", line 459, 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 1533, in process_api
result = await self.call_function(
File "/home/user/.local/lib/python3.10/site-packages/gradio/blocks.py", line 1151, 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 678, in wrapper
response = f(*args, **kwargs)
File "/home/user/.local/lib/python3.10/site-packages/gradio_client/client.py", line 959, in _inner
predictions = _predict(*data)
File "/home/user/.local/lib/python3.10/site-packages/gradio_client/client.py", line 994, in _predict
result = utils.synchronize_async(self._sse_fn_v1, helper, event_id)
File "/home/user/.local/lib/python3.10/site-packages/gradio_client/utils.py", line 808, 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 1188, in _sse_fn_v1
return await utils.get_pred_from_sse_v1(
File "/home/user/.local/lib/python3.10/site-packages/gradio_client/utils.py", line 412, in get_pred_from_sse_v1
assert len(done) == 1
AssertionError
Traceback (most recent call last):
File "/home/user/.local/lib/python3.10/site-packages/gradio/queueing.py", line 459, 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 1533, in process_api
result = await self.call_function(
File "/home/user/.local/lib/python3.10/site-packages/gradio/blocks.py", line 1151, 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 678, in wrapper
response = f(*args, **kwargs)
File "/home/user/.local/lib/python3.10/site-packages/gradio_client/client.py", line 959, in _inner
predictions = _predict(*data)
File "/home/user/.local/lib/python3.10/site-packages/gradio_client/client.py", line 994, in _predict
result = utils.synchronize_async(self._sse_fn_v1, helper, event_id)
File "/home/user/.local/lib/python3.10/site-packages/gradio_client/utils.py", line 808, 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 1188, in _sse_fn_v1
return await utils.get_pred_from_sse_v1(
File "/home/user/.local/lib/python3.10/site-packages/gradio_client/utils.py", line 412, in get_pred_from_sse_v1
assert len(done) == 1
AssertionError

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 497, in process_events
response = await self.call_prediction(awake_events, batch)
File "/home/user/.local/lib/python3.10/site-packages/gradio/queueing.py", line 468, in call_prediction
raise Exception(str(error) if show_error else None) from error
Exception: None

@abidlabs
Copy link
Member

I should have a fix for the core issue soon: #6810

@amitagh
Copy link
Author

amitagh commented Jan 27, 2024 via email

@abidlabs
Copy link
Member

Are you running into this issue? #6744

I'm working on a fix

@amitagh
Copy link
Author

amitagh commented Jan 28, 2024 via email

@avfranco-br
Copy link

Hi @abidlabs, just to share that I'm facing same issue as below. Thanks.

Fetching Space from: https://huggingface.co/spaces/avfranco/ArchitectGPT
Loaded as API: https://avfranco-architectgpt.hf.space
Traceback (most recent call last):
File "/home/user/app/app.py", line 6, in
demo = gr.load(name="avfranco/ArchitectGPT", hf_token=token, src='spaces')
File "/home/user/.local/lib/python3.10/site-packages/gradio/external.py", line 72, in load
return load_blocks_from_repo(
File "/home/user/.local/lib/python3.10/site-packages/gradio/external.py", line 111, in load_blocks_from_repo
blocks: gradio.Blocks = factory_methods[src](name, hf_token, alias, **kwargs)
File "/home/user/.local/lib/python3.10/site-packages/gradio/external.py", line 521, in from_spaces
return from_spaces_blocks(space=space_name, hf_token=hf_token)
File "/home/user/.local/lib/python3.10/site-packages/gradio/external.py", line 539, in from_spaces_blocks
return gradio.Blocks.from_config(client.config, predict_fns, client.src)
File "/home/user/.local/lib/python3.10/site-packages/gradio/blocks.py", line 730, in from_config
targets = [
File "/home/user/.local/lib/python3.10/site-packages/gradio/blocks.py", line 732, in
original_mapping[
KeyError: None

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