Spaces:
Runtime error
Runtime error
CognitiveScience
commited on
Commit
•
da68b17
1
Parent(s):
517d75b
Update app.py
Browse files
app.py
CHANGED
@@ -17,6 +17,9 @@ import random
|
|
17 |
import time
|
18 |
import requests
|
19 |
|
|
|
|
|
|
|
20 |
|
21 |
DB_FILE = "./reviews.db"
|
22 |
|
@@ -31,7 +34,7 @@ repo = huggingface_hub.Repository(
|
|
31 |
repo.git_pull()
|
32 |
|
33 |
# Set db to latest
|
34 |
-
|
35 |
|
36 |
# Create table if it doesn't already exist
|
37 |
|
@@ -120,7 +123,7 @@ def backup_db():
|
|
120 |
shutil.copyfile(DB_FILE, "./reviews02.db")
|
121 |
db = sqlite3.connect(DB_FILE)
|
122 |
reviews = db.execute("SELECT * FROM reviews").fetchall()
|
123 |
-
pd.DataFrame(reviews).to_csv("./
|
124 |
print("updating db")
|
125 |
repo.push_to_hub(blocking=False, commit_message=f"Updating data at {datetime.datetime.now()}")
|
126 |
|
@@ -132,11 +135,11 @@ def backup_db():
|
|
132 |
# #return reviews, total_reviews
|
133 |
|
134 |
scheduler2 = BackgroundScheduler()
|
135 |
-
scheduler2.add_job(func=run_actr, trigger="interval", seconds=
|
136 |
scheduler2.start()
|
137 |
|
138 |
scheduler2 = BackgroundScheduler()
|
139 |
-
scheduler2.add_job(func=backup_db, trigger="interval", seconds=
|
140 |
scheduler2.start()
|
141 |
|
142 |
demo.launch()
|
|
|
17 |
import time
|
18 |
import requests
|
19 |
|
20 |
+
from huggingface_hub import hf_hub_download
|
21 |
+
|
22 |
+
hf_hub_download(repo_id="CogSphere/aCogSphere", filename="./reviews.csv")
|
23 |
|
24 |
DB_FILE = "./reviews.db"
|
25 |
|
|
|
34 |
repo.git_pull()
|
35 |
|
36 |
# Set db to latest
|
37 |
+
shutil.copyfile("./data/reviews01.db", DB_FILE)
|
38 |
|
39 |
# Create table if it doesn't already exist
|
40 |
|
|
|
123 |
shutil.copyfile(DB_FILE, "./reviews02.db")
|
124 |
db = sqlite3.connect(DB_FILE)
|
125 |
reviews = db.execute("SELECT * FROM reviews").fetchall()
|
126 |
+
pd.DataFrame(reviews).to_csv("./reviews1.csv", index=False)
|
127 |
print("updating db")
|
128 |
repo.push_to_hub(blocking=False, commit_message=f"Updating data at {datetime.datetime.now()}")
|
129 |
|
|
|
135 |
# #return reviews, total_reviews
|
136 |
|
137 |
scheduler2 = BackgroundScheduler()
|
138 |
+
scheduler2.add_job(func=run_actr, trigger="interval", seconds=60)
|
139 |
scheduler2.start()
|
140 |
|
141 |
scheduler2 = BackgroundScheduler()
|
142 |
+
scheduler2.add_job(func=backup_db, trigger="interval", seconds=90)
|
143 |
scheduler2.start()
|
144 |
|
145 |
demo.launch()
|