mrfakename commited on
Commit
6234be3
1 Parent(s): 5caa0cd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -1
app.py CHANGED
@@ -1,5 +1,6 @@
1
  import time
2
  last_run = 0
 
3
  import os
4
  from huggingface_hub import HfApi
5
  api = HfApi(
@@ -15,8 +16,19 @@ def reboot():
15
  return "Rebooted"
16
  else:
17
  raise 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()
 
1
  import time
2
  last_run = 0
3
+ olast_run = 0
4
  import os
5
  from huggingface_hub import HfApi
6
  api = HfApi(
 
16
  return "Rebooted"
17
  else:
18
  raise gr.Error("The Space has already been rebooted recently")
19
+ def rebootorig():
20
+ global olast_run
21
+ current_time = time.time()
22
+ if current_time - olast_run >= 300:
23
+ api.restart_space('mrfakename/OpenDalle-GPU-Demo', factory_reboot=True)
24
+ olast_run = current_time
25
+ return "Rebooted"
26
+ else:
27
+ raise gr.Error("The Space has already been rebooted recently")
28
  with gr.Blocks() as demo:
29
  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!")
30
+ btn = gr.Button("Reboot V1.1 GPU DEMO")
31
  btn.click(reboot, outputs=[btn])
32
+ btnorig = gr.Button("Reboot V1 (original) GPU DEMO")
33
+ btnorig.click(rebootorig, outputs=[btnorig])
34
  demo.launch()