sharner commited on
Commit
8d262db
·
1 Parent(s): 3e4d5e4

Scheduled restart

Browse files
Files changed (2) hide show
  1. app.py +11 -0
  2. requirements.txt +3 -1
app.py CHANGED
@@ -3,6 +3,13 @@ import hopsworks
3
  import pandas as pd
4
  import gradio as gr
5
  from datetime import datetime
 
 
 
 
 
 
 
6
 
7
  today = datetime.now().strftime('%Y-%m-%d')
8
 
@@ -51,4 +58,8 @@ with gr.Blocks() as demo:
51
  gr.Label("Sentiment History of News on this Demo")
52
  gr.Image("demo_sentiment_history.png", elem_id="demo-history")
53
 
 
 
 
 
54
  demo.launch()
 
3
  import pandas as pd
4
  import gradio as gr
5
  from datetime import datetime
6
+ from huggingface_hub import HfApi
7
+ from apscheduler.schedulers.background import BackgroundScheduler
8
+
9
+ HFAPI = HfApi()
10
+
11
+ def restart_space():
12
+ HFAPI.restart_space(repo_id="DelightNews/the-delight-dispatch-demo")
13
 
14
  today = datetime.now().strftime('%Y-%m-%d')
15
 
 
58
  gr.Label("Sentiment History of News on this Demo")
59
  gr.Image("demo_sentiment_history.png", elem_id="demo-history")
60
 
61
+ scheduler = BackgroundScheduler()
62
+ scheduler.add_job(restart_space, 'cron', hour=16, minute=22)
63
+ scheduler.start()
64
+
65
  demo.launch()
requirements.txt CHANGED
@@ -2,4 +2,6 @@ pillow
2
  hopsworks
3
  httpx==0.24.1
4
  pandas
5
- datetime
 
 
 
2
  hopsworks
3
  httpx==0.24.1
4
  pandas
5
+ datetime
6
+ huggingface-hub
7
+ APScheduler