Spaces:
Running
Running
mrfakename
commited on
Commit
•
9d1fc61
1
Parent(s):
20dc216
Add autorestart
Browse files
app.py
CHANGED
@@ -25,6 +25,9 @@ import os
|
|
25 |
import pandas as pd
|
26 |
import sqlite3
|
27 |
from datasets import load_dataset
|
|
|
|
|
|
|
28 |
|
29 |
dataset = load_dataset("ttseval/tts-arena", token=os.getenv('HF_TOKEN'))
|
30 |
theme = gr.themes.Base(
|
@@ -188,4 +191,15 @@ with gr.Blocks() as vote:
|
|
188 |
with gr.Blocks(theme=theme, css="footer {visibility: hidden}") as demo:
|
189 |
gr.Markdown(DESCR)
|
190 |
gr.TabbedInterface([vote, leaderboard], ['Vote', 'Leaderboard'])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
191 |
demo.queue(api_open=False).launch(show_api=False)
|
|
|
25 |
import pandas as pd
|
26 |
import sqlite3
|
27 |
from datasets import load_dataset
|
28 |
+
import threading
|
29 |
+
import time
|
30 |
+
from huggingface_hub import HfApi
|
31 |
|
32 |
dataset = load_dataset("ttseval/tts-arena", token=os.getenv('HF_TOKEN'))
|
33 |
theme = gr.themes.Base(
|
|
|
191 |
with gr.Blocks(theme=theme, css="footer {visibility: hidden}") as demo:
|
192 |
gr.Markdown(DESCR)
|
193 |
gr.TabbedInterface([vote, leaderboard], ['Vote', 'Leaderboard'])
|
194 |
+
def restart_space():
|
195 |
+
time.sleep(60)
|
196 |
+
print("Restarting space")
|
197 |
+
api = HfApi(
|
198 |
+
token=os.getenv('HF_TOKEN')
|
199 |
+
)
|
200 |
+
api.restart_space(repo_id=os.getenv('HF_ID'))
|
201 |
+
if os.getenv('HF_ID'):
|
202 |
+
restart_thread = threading.Thread(target=restart_space)
|
203 |
+
restart_thread.daemon = True
|
204 |
+
restart_thread.start()
|
205 |
demo.queue(api_open=False).launch(show_api=False)
|