Spaces:
Runtime error
Runtime error
test restart
Browse files
app.py
CHANGED
@@ -209,6 +209,9 @@ def button_click(hf_model_id, conv_template, quantization, oauth_token: gr.OAuth
|
|
209 |
def clean():
|
210 |
os.system("rm -rf dist/")
|
211 |
|
|
|
|
|
|
|
212 |
with gr.Blocks() as demo:
|
213 |
gr.LoginButton()
|
214 |
gr.Markdown(
|
@@ -227,10 +230,12 @@ with gr.Blocks() as demo:
|
|
227 |
btn2 = gr.Button("Cancel Conversion")
|
228 |
out = gr.Textbox(label="Conversion Result")
|
229 |
click_event = btn.click(fn=button_click , inputs=[model_id, conv, quant], outputs=out)
|
230 |
-
btn2.click(fn=
|
|
|
231 |
|
232 |
scheduler = BackgroundScheduler()
|
233 |
scheduler.add_job(clean, "interval", seconds=21600)
|
|
|
234 |
scheduler.start()
|
235 |
|
236 |
demo.queue(max_size=5).launch()
|
|
|
209 |
def clean():
|
210 |
os.system("rm -rf dist/")
|
211 |
|
212 |
+
def restart_space():
|
213 |
+
HfApi().restart_space(repo_id="", token=os.environ.get("HF_TOKEN"), factory_reboot=True)
|
214 |
+
|
215 |
with gr.Blocks() as demo:
|
216 |
gr.LoginButton()
|
217 |
gr.Markdown(
|
|
|
230 |
btn2 = gr.Button("Cancel Conversion")
|
231 |
out = gr.Textbox(label="Conversion Result")
|
232 |
click_event = btn.click(fn=button_click , inputs=[model_id, conv, quant], outputs=out)
|
233 |
+
# btn2.click(fn=restart_space, inputs=None, outputs=None, cancels=[click_event], js="window.location.reload()")
|
234 |
+
btn2.click(fn=restart_space, inputs=None, outputs=None)
|
235 |
|
236 |
scheduler = BackgroundScheduler()
|
237 |
scheduler.add_job(clean, "interval", seconds=21600)
|
238 |
+
scheduler.add_job(restart_space, "interval", seconds=86400)
|
239 |
scheduler.start()
|
240 |
|
241 |
demo.queue(max_size=5).launch()
|