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

Spaces auto-generated from push_to_hub raises an error #4941

Closed
1 task done
deepkyu opened this issue Jul 17, 2023 · 2 comments · Fixed by #4944
Closed
1 task done

Spaces auto-generated from push_to_hub raises an error #4941

deepkyu opened this issue Jul 17, 2023 · 2 comments · Fixed by #4944
Labels
bug Something isn't working

Comments

@deepkyu
Copy link
Contributor

deepkyu commented Jul 17, 2023

Describe the bug

When we execute push_to_hub following the Theming Guide, pushing to space works and uploading theme also works.
However, the example demo in Hugging Face Spaces raises an runtime error.

I found out that push_to_hub copy the app.py code, which is different from the file for the current theme builder, builder_app.py.

contents = (Path(__file__).parent / "app.py").read_text()

It seems that error is raised because the default image link https://gradio.app/assets/img/header-image.jpg in app.py is expired (maybe after the update for converting the website into sveltekit).

img = gr.Image(
"https://gradio.app/assets/img/header-image.jpg", label="Image"
).style(height=320)

In builder_app.py which is used in gr.themes.builder(), the default image link is different from app.py.

img = gr.Image(
"https://i.ibb.co/6BgKdSj/groot.jpg", label="Image", height=320
)

You can see the error in my current space at my theme space (I'll close the space when this issue is closed).

The link in the below is the problematic line in space demo, which seems to be copied from app.py.

https://huggingface.co/spaces/deepkyu/theme_push_to_hub_v3.36.1/blob/14cb1caac1dd7173679f73fbbcea6e9de89d6db3/app.py#L65-L67

Have you searched existing issues? 🔎

  • I have searched and found no existing issues

Reproduction

Please make your own theme and execute:

import gradio as gr

my_theme = gr.themes.Base()
my_theme .push_to_hub(
    repo_name="theme",
    version="0.0.1-test",
    hf_token=<token>
) 

Then, please visit https://huggingface.co/spaces/<your-id>/theme. It will show a runtime error.
Or, if you build again Spaces in Hugging Face pushed by push_to_hub, it will raise an error.

Screenshot

Screenshot-2023-07-17-223855

Logs

Traceback (most recent call last):
  File "/home/user/app/app.py", line 65, in <module>
    img = gr.Image(
  File "/home/user/.local/lib/python3.10/site-packages/gradio/components/image.py", line 149, in __init__
    IOComponent.__init__(
  File "/home/user/.local/lib/python3.10/site-packages/gradio/components/base.py", line 176, in __init__
    else self.postprocess(initial_value)
  File "/home/user/.local/lib/python3.10/site-packages/gradio/components/image.py", line 296, in postprocess
    return client_utils.encode_url_or_file_to_base64(y)
  File "/home/user/.local/lib/python3.10/site-packages/gradio_client/utils.py", line 372, in encode_url_or_file_to_base64
    return encode_url_to_base64(path)
  File "/home/user/.local/lib/python3.10/site-packages/gradio_client/utils.py", line 360, in encode_url_to_base64
    resp.raise_for_status()
  File "/home/user/.local/lib/python3.10/site-packages/requests/models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://www.gradio.app/assets/img/header-image.jpg

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user/app/app.py", line 8, in <module>
    with gr.Blocks(theme='deepkyu/theme_push_to_hub_v3.36.1') as demo:
  File "/home/user/.local/lib/python3.10/site-packages/gradio/blocks.py", line 1472, in __exit__
    self.config = self.get_config_file()
  File "/home/user/.local/lib/python3.10/site-packages/gradio/blocks.py", line 1439, in get_config_file
    props = block.get_config() if hasattr(block, "get_config") else {}
  File "/home/user/.local/lib/python3.10/site-packages/gradio/components/image.py", line 174, in get_config
    "value": self.value,
AttributeError: 'Image' object has no attribute 'value'

System Info

gradio==3.36.1

However, it is not version-specific issue because it happens from the broken link.

Severity

I can work around it

@deepkyu deepkyu added the bug Something isn't working label Jul 17, 2023
@abidlabs
Copy link
Member

Thanks @deepkyu for creating this issue and opening a PR. I'll take a look at the PR shortly

@deepkyu
Copy link
Contributor Author

deepkyu commented Jul 17, 2023

Really minor issue.... but hope it helps :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants