Accessing data in a private space from a public space
I have two spaces: a private space which contains image files and displays them in a gradio gallery, and a public space which loads this private space to run the app. The issue I am running into is that the images are loaded correctly while using the app in the private space, but the app in the public space fails to load them (the app continues running, just fails to load the data).Does anyone know why a public space that loads a private space would not correctly load data? Is there some sort of permission that needs to be given to the public space to access this data? I’m at a loss and would greatly appreciate any and all help!
2023-08-16T10:08:21Z
Hello@BBongiovanni,Your second space being private the first one does not have access to it. A space does not have the permissions you have as a user.To use your private space from the public one you’ll need to specify a token.From your account generate a readaccess tokenthen add a header to your requests of the formAuthorization: Bearer $HF_TOKENYou can create a secret in your space settings to set this token to be used a runtime as an environment variable.
2023-08-16T14:58:40Z
Thank you for your response! Below is the app.py file in the public space. I am not making a request, but rather loading a gradio Hugging Face repo. Is it possible to specify a Bearer token using this method? Or should I go about loading a private space in a different manner?I really appreciate your help - I was close to giving up on this project entirely!import os
import gradio as gr

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

with gr.Blocks() as demo:
    gr.load("BBongiovanni/vexilink_private", api_key=read_key, REDACTED_TOKEN=read_key, src="spaces")

demo.queue(concurrency_count=10, max_size=20)
demo.launch()
2023-08-16T15:47:58Z
According to theGradio documentationthe parameterREDACTED_TOKEN available.So creating a secret in your space’s settingsHF_TOKEN=<access_token>you should be able to run:import os
import gradio as gr

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

with gr.Blocks() as demo:
    gr.load("BBongiovanni/vexilink_private", REDACTED_TOKEN=read_key, src="spaces")

demo.queue(concurrency_count=10, max_size=20)
demo.launch()
2023-08-16T16:11:10Z
@chris-rannouI created a new READ access token in my profile and added its contents as a secret in the public repo. Used the code you provided and still no luck.The token is obviously being used correctly as we can run the app in the public space (https://huggingface.co/spaces/BBongiovanni/vexilink), but when the gradio gallery object is populated, none of the images show up… I’m stumped…
2023-08-17T06:56:28Z
Do the images display correctly on the private space ?
2023-08-17T13:12:30Z
@chris-rannouYep, that’s correct. The app in the public space works as expected EXCEPT that the images that should be rendered in the gradio gallery are not. Their titles do, however. Here are two pictures of what the private and public space gives us.Private space (works perfectly)Screenshot 2023-08-17 at 9.08.23 AM1722×953 94.2 KBPublic space (works perfectly EXCEPT the images do not appear)Screenshot 2023-08-17 at 9.08.48 AM1721×1060 42.2 KB
2023-10-16T13:34:14Z
Getting below error while loading a pvt space from public 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”, REDACTED_TOKEN = REDACTED_TOKEN, api_key = REDACTED_TOKEN)Traceback (most recent call last):File “/home/user/app/app.py”, line 9, indemo = gr.load(name=“spaces/amitagh/TestChatIntf”, REDACTED_TOKEN = REDACTED_TOKEN, api_key = REDACTED_TOKEN)File “/home/user/.local/lib/python3.10/site-packages/gradio/external.py”, line 70, in loadreturn load_blocks_from_repo(File “/home/user/.local/lib/python3.10/site-packages/gradio/external.py”, line 109, in load_blocks_from_repoblocks: gradio.Blocks = factory_methods[src](name, REDACTED_TOKEN, alias, **kwargs)File “/home/user/.local/lib/python3.10/site-packages/gradio/external.py”, line 504, in from_spacesreturn from_spaces_blocks(space=space_name, REDACTED_TOKEN=REDACTED_TOKEN)File “/home/user/.local/lib/python3.10/site-packages/gradio/external.py”, line 510, in from_spaces_blocksreturn 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_configtargets = [File “/home/user/.local/lib/python3.10/site-packages/gradio/blocks.py”, line 803, inoriginal_mapping[KeyError: Nonemore details heregr.load() failing with Error · Issue #5927 · gradio-app/gradio · GitHub.Have you come across something similar.Pvt space is working fine but public space has this error while loading.
2024-01-24T17:15:24Z
Hi! Not sure if you’re still having this issue, but I came upon your post because I had a similar question. Here’s the solution! I loaded my private space using a token as an environmental variable as discussed earlier in this thread.Then I used my private space as a functionand that worked perfectly! Here’s the Gradio documentation for how to use a block like a function:Using Blocks Like FunctionsEither way, I hope this helps someone because it took me a while to figure out lol
2024-03-27T15:08:14Z
Can you show me how you did so, because the functionality of my private repo is not working, the buttons for example