File size: 1,482 Bytes
0fc235e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env python
from pathlib import Path

import gradio as gr
from gradio_space_ci import configure_space_ci


def greet(name: str) -> str:
    return "Hello " + name + "!"


with gr.Blocks() as demo:
    gr.Markdown("## Dummy gradio app to showcase gradio-space-ci")
    name = gr.Textbox(label="Name")
    output = gr.Textbox(label="Output Box")
    greet_btn = gr.Button("Greet")
    greet_btn.click(fn=greet, inputs=name, outputs=output, api_name="greet")


with gr.Blocks() as demo_with_readme:
    with gr.Tab("README"):
        gr.Markdown(Path("README.md").read_text().split("---")[-1])
    with gr.Tab("Demo"):
        demo.render()

if __name__ == "__main__":
    configure_space_ci(
        blocks=demo_with_readme.queue(),  # ANY gradio app
        trusted_authors=["clefourrier"],  # space owners + manually trusted authors
        private="auto",  # ephemeral spaces will have same visibility as the main space. Otherwise, set to `True` or `False` explicitly.
        variables="auto",  # same variables as the main space. Otherwise, set to a `Dict[str, str]`.
        secrets=["HF_TOKEN"],  # which secret do I want to copy from the main space? Can be a `List[str]`.
        hardware=None,  # "cpu-basic" by default. Otherwise set to "auto" to have same hardware as the main space or any valid string value.
        storage=None,  # no storage by default. Otherwise set to "auto" to have same storage as the main space or any valid string value.
    ).launch()