Spaces:
Runtime error
Runtime error
Add Background Scheduler for daily refresh (#59)
Browse files- Update app.py (b94ff31589bb2c3307211ee10eb6889e58c25e20)
app.py
CHANGED
@@ -11,9 +11,12 @@ from huggingface_hub import ModelCard
|
|
11 |
|
12 |
from gradio_huggingfacehub_search import HuggingfaceHubSearch
|
13 |
|
|
|
|
|
14 |
from textwrap import dedent
|
15 |
|
16 |
LLAMA_LIKE_ARCHS = ["MistralForCausalLM",]
|
|
|
17 |
|
18 |
def script_to_use(model_id, api):
|
19 |
info = api.model_info(model_id)
|
@@ -177,5 +180,12 @@ with gr.Blocks() as demo:
|
|
177 |
gr.LoginButton(min_width=250)
|
178 |
iface.render()
|
179 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
180 |
# Launch the interface
|
181 |
demo.queue(default_concurrency_limit=1, max_size=5).launch(debug=True)
|
|
|
11 |
|
12 |
from gradio_huggingfacehub_search import HuggingfaceHubSearch
|
13 |
|
14 |
+
from apscheduler.schedulers.background import BackgroundScheduler
|
15 |
+
|
16 |
from textwrap import dedent
|
17 |
|
18 |
LLAMA_LIKE_ARCHS = ["MistralForCausalLM",]
|
19 |
+
HF_TOKEN = os.environ.get("HF_TOKEN")
|
20 |
|
21 |
def script_to_use(model_id, api):
|
22 |
info = api.model_info(model_id)
|
|
|
180 |
gr.LoginButton(min_width=250)
|
181 |
iface.render()
|
182 |
|
183 |
+
def restart_space():
|
184 |
+
HfApi().restart_space(repo_id="ggml-org/gguf-my-repo", token=HF_TOKEN)
|
185 |
+
|
186 |
+
scheduler = BackgroundScheduler()
|
187 |
+
scheduler.add_job(restart_space, "interval", seconds=86400)
|
188 |
+
scheduler.start()
|
189 |
+
|
190 |
# Launch the interface
|
191 |
demo.queue(default_concurrency_limit=1, max_size=5).launch(debug=True)
|