File size: 1,627 Bytes
7724338
 
6234be3
bba1f64
 
 
 
 
7724338
 
 
 
 
bba1f64
7724338
fab6487
7724338
fab6487
6234be3
 
 
 
 
 
fab6487
6234be3
ab88861
7724338
c1b35c8
6234be3
bba1f64
af78480
 
7724338
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
import time
last_run = 0
olast_run = 0
import os
from huggingface_hub import HfApi
api = HfApi(
    token=os.getenv('HF_TOKEN'),
)
import gradio as gr
def reboot():
    global last_run
    current_time = time.time()
    if current_time - last_run >= 300:
        api.restart_space('mrfakename/OpenDalleV1.1-GPU-Demo', factory_reboot=True)
        last_run = current_time
        return "Rebooted. Thank you!"
    else:
        raise gr.Error("The Space has already been rebooted recently, please try again in 5 minutes.")
def rebootorig():
    global olast_run
    current_time = time.time()
    if current_time - olast_run >= 300:
        api.restart_space('mrfakename/OpenDalle-GPU-Demo', factory_reboot=True)
        olast_run = current_time
        return "Rebooted. Thank you!"
    else:
        raise gr.Error("The Space has already been rebooted recently, please try again in 5 minutes.")
with gr.Blocks() as demo:
    gr.Markdown("# Request a Reboot of OpenDalle v1.1 GPU Demo\n\nIs [the demo](https://huggingface.co/spaces/mrfakename/OpenDalleV1.1-GPU-Demo) not working? Request a reboot!\n\nNOTE: Feel free to Duplicate this space and use it for your own projects. It's good to let your users reboot the Space if it goes down (link to it in a pinned Discussion, not your Space itself, since your Space will be inaccessible if it goes down). If you do duplicate, please link back to this original space. Thanks :)")
    btn = gr.Button("Reboot V1.1 GPU DEMO")
    btn.click(reboot, outputs=[btn])
    #btnorig = gr.Button("Reboot V1 (original) GPU DEMO")
    #btnorig.click(rebootorig, outputs=[btnorig])
demo.launch()