Spaces:
Runtime error
Runtime error
CognitiveScience
commited on
Commit
•
2274ab7
1
Parent(s):
f8df093
Update app.py
Browse files
app.py
CHANGED
@@ -29,7 +29,7 @@ import time
|
|
29 |
#hf_hub_download(repo_id="CogSphere/aCogSphere", filename="./reviews.csv")
|
30 |
|
31 |
#from huggingface_hub import login
|
32 |
-
|
33 |
|
34 |
#dataset = load_dataset("csv", data_files="./data.csv")
|
35 |
|
@@ -81,11 +81,11 @@ def get_latest_reviews(): #db: sqlite3.Connection):
|
|
81 |
reviews = pd.DataFrame(reviews, columns=["id", "date_created", "name", "view", "duration"])
|
82 |
return reviews, total_reviews
|
83 |
|
84 |
-
def get_latest_reviews2(db: sqlite3.Connection):
|
85 |
-
reviews2 = db.execute("SELECT * FROM reviews2 ORDER BY id DESC limit 100").fetchall()
|
86 |
-
total_reviews2 = db.execute("Select COUNT(id) from reviews2").fetchone()[0]
|
87 |
-
reviews2 = pd.DataFrame(reviews2, columns=["id","title", "link","channel", "description", "views", "uploaded", "duration", "durationString"])
|
88 |
-
return reviews2, total_reviews2
|
89 |
|
90 |
def ccogsphere(name: str, rate: int, celsci: str):
|
91 |
#db = sqlite3.connect(DB_FILE)
|
@@ -156,11 +156,11 @@ def load_data():
|
|
156 |
reviews, total_reviews = get_latest_reviews(db)
|
157 |
#db.close()
|
158 |
return reviews, total_reviews
|
159 |
-
def load_data2():
|
160 |
-
db = sqlite3.connect(DB_FILE)
|
161 |
-
reviews2, total_reviews2 = get_latest_reviews2(db)
|
162 |
-
db.close()
|
163 |
-
return reviews2, total_reviews2
|
164 |
|
165 |
css="footer {visibility: hidden}"
|
166 |
# Applying style to highlight the maximum value in each row
|
@@ -189,17 +189,17 @@ with gr.Blocks(css=css) as demo:
|
|
189 |
load_data()
|
190 |
#return "Hello " + name + "!"
|
191 |
def backup_db():
|
192 |
-
shutil.copyfile(DB_FILE, "./reviews.db")
|
193 |
-
db = sqlite3.connect(DB_FILE)
|
194 |
-
reviews = db.execute("SELECT * FROM reviews").fetchall()
|
195 |
pd.DataFrame(reviews).to_csv("./reviews.csv", index=False)
|
196 |
print("updating db")
|
197 |
repo.push_to_hub(blocking=False, commit_message=f"Updating data at {datetime.datetime.now()}")
|
198 |
|
199 |
def backup_db_csv():
|
200 |
-
shutil.copyfile(DB_FILE, "./reviews2.db")
|
201 |
-
db = sqlite3.connect(DB_FILE)
|
202 |
-
reviews = db.execute("SELECT * FROM reviews").fetchall()
|
203 |
pd.DataFrame(reviews).to_csv("./reviews2.csv", index=False)
|
204 |
print("updating db csv")
|
205 |
dataset = load_dataset("csv", data_files="./reviews2.csv")
|
|
|
29 |
#hf_hub_download(repo_id="CogSphere/aCogSphere", filename="./reviews.csv")
|
30 |
|
31 |
#from huggingface_hub import login
|
32 |
+
from datasets import load_dataset
|
33 |
|
34 |
#dataset = load_dataset("csv", data_files="./data.csv")
|
35 |
|
|
|
81 |
reviews = pd.DataFrame(reviews, columns=["id", "date_created", "name", "view", "duration"])
|
82 |
return reviews, total_reviews
|
83 |
|
84 |
+
#def get_latest_reviews2(db: sqlite3.Connection):
|
85 |
+
# reviews2 = db.execute("SELECT * FROM reviews2 ORDER BY id DESC limit 100").fetchall()
|
86 |
+
# total_reviews2 = db.execute("Select COUNT(id) from reviews2").fetchone()[0]
|
87 |
+
# reviews2 = pd.DataFrame(reviews2, columns=["id","title", "link","channel", "description", "views", "uploaded", "duration", "durationString"])
|
88 |
+
# return reviews2, total_reviews2
|
89 |
|
90 |
def ccogsphere(name: str, rate: int, celsci: str):
|
91 |
#db = sqlite3.connect(DB_FILE)
|
|
|
156 |
reviews, total_reviews = get_latest_reviews(db)
|
157 |
#db.close()
|
158 |
return reviews, total_reviews
|
159 |
+
#def load_data2():
|
160 |
+
# db = sqlite3.connect(DB_FILE)
|
161 |
+
# reviews2, total_reviews2 = get_latest_reviews2(db)
|
162 |
+
# db.close()
|
163 |
+
# return reviews2, total_reviews2
|
164 |
|
165 |
css="footer {visibility: hidden}"
|
166 |
# Applying style to highlight the maximum value in each row
|
|
|
189 |
load_data()
|
190 |
#return "Hello " + name + "!"
|
191 |
def backup_db():
|
192 |
+
#shutil.copyfile(DB_FILE, "./reviews.db")
|
193 |
+
#db = sqlite3.connect(DB_FILE)
|
194 |
+
#reviews = db.execute("SELECT * FROM reviews").fetchall()
|
195 |
pd.DataFrame(reviews).to_csv("./reviews.csv", index=False)
|
196 |
print("updating db")
|
197 |
repo.push_to_hub(blocking=False, commit_message=f"Updating data at {datetime.datetime.now()}")
|
198 |
|
199 |
def backup_db_csv():
|
200 |
+
#shutil.copyfile(DB_FILE, "./reviews2.db")
|
201 |
+
#db = sqlite3.connect(DB_FILE)
|
202 |
+
#reviews = db.execute("SELECT * FROM reviews").fetchall()
|
203 |
pd.DataFrame(reviews).to_csv("./reviews2.csv", index=False)
|
204 |
print("updating db csv")
|
205 |
dataset = load_dataset("csv", data_files="./reviews2.csv")
|