Commit
·
bba1f64
1
Parent(s):
7724338
Update app.py
Browse files
app.py
CHANGED
@@ -1,16 +1,22 @@
|
|
1 |
import time
|
2 |
last_run = 0
|
|
|
|
|
|
|
|
|
|
|
3 |
import gradio as gr
|
4 |
def reboot():
|
5 |
global last_run
|
6 |
current_time = time.time()
|
7 |
if current_time - last_run >= 300:
|
|
|
8 |
last_run = current_time
|
9 |
-
|
10 |
else:
|
11 |
gr.Error("The Space has already been rebooted recently")
|
12 |
with gr.Blocks() as demo:
|
13 |
-
gr.Markdown("# Request a Reboot of
|
14 |
btn = gr.Button("Reboot")
|
15 |
-
btn.click(reboot)
|
16 |
demo.launch()
|
|
|
1 |
import time
|
2 |
last_run = 0
|
3 |
+
import os
|
4 |
+
from huggingface_hub import HfApi
|
5 |
+
api = HfApi(
|
6 |
+
token=os.getenv('HF_TOKEN'),
|
7 |
+
)
|
8 |
import gradio as gr
|
9 |
def reboot():
|
10 |
global last_run
|
11 |
current_time = time.time()
|
12 |
if current_time - last_run >= 300:
|
13 |
+
api.restart_space('mrfakename/OpenDalleV1.1-GPU-Demo', factory_reboot=True)
|
14 |
last_run = current_time
|
15 |
+
return "Rebooted"
|
16 |
else:
|
17 |
gr.Error("The Space has already been rebooted recently")
|
18 |
with gr.Blocks() as demo:
|
19 |
+
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!")
|
20 |
btn = gr.Button("Reboot")
|
21 |
+
btn.click(reboot, outputs=[btn])
|
22 |
demo.launch()
|