Embedding Spaces with auth for public models counter-intuitive?

Thank you very much @radames, updating the sdk worked perfectly.

1 Like

Hi, anyone managed to solve this? Getting the same error

for fn_index, dependency in enumerate(self.config["dependencies"])

KeyError: ‘dependencies’

Using both gr.load and gradio_client results in the same error, the objective is to load a gradio app from a private space into a public space.

import gradio as gr
from gradio_client import Client
import os

HF_TOKEN = os.environ.get(“hfkey”)

gr.load(name=“spaces/xxx/yyy”, api_key=HF_TOKEN).launch()

#both method below resulted in the same error
#client = Client(“xxx/yyy”, hf_token=HF_TOKEN)
#client = Client.duplicate(“xxx/yyy”, hf_token=HF_TOKEN)

Hi @bentobytes ! The demo you’re trying to load has authentication enabled?

Hi @freddyaboulton , yes indeed i had authentication enabled, I managed to make it work! Thanks alot for your guidance

I too had the error:

for fn_index, dependency in enumerate(self.config["dependencies"])

KeyError: ‘dependencies’

I figured out the reason was that I had “auth=” turned on in the private space. Apparently, this is what caused the gr.load to throw this error in the public space.

Since I still wanted to have auth=, so I turned it on the public space, and it works fine now…

I have the same of a similar problem. I have a private space like this

import gradio as gr

def greet(name):
    return "Hello " + name + "!!"

iface = gr.Interface(fn=greet, inputs="text", outputs="text")
iface.launch()

and a public space like this:

import os
import gradio as gr

read_key = os.environ.get('HF_TOKEN', None)

# the space is displayed, but does nothing
with gr.Blocks() as demo:
    # the loaded space should have the same version as the one it is loaded in
    # take from the space
    # take the provided hf_token
    gr.load("jen5000/demo_classification", hf_token=read_key, src="spaces")


# login works
def environ_auth(username, password):
    if username == os.environ["username"] and password == os.environ["password"]:
        return True
    else:
        return False
    

demo.queue(max_size=20)
demo.launch(auth=environ_auth).launch()

I launch the private space in the public space, but when I push the submit button of the launched space nothing happens. Is there something I am doing wrong?

SDK Versions are both 4.5.0

Cheers Jenny

Maybe due to this bug?
Gradio APIs breaks calling private endpoints on HF · Issue #6430 · gradio-app/gradio · GitHub

@freddyaboulton I am getting the following error:

File "/usr/local/lib/python3.10/site-packages/gradio/blocks.py", line 853, in from_config
    dependency.pop("zerogpu")
KeyError: 'zerogpu'

Any idea what is going wrong?