lixuejing
commited on
Commit
·
954086e
1
Parent(s):
6f31b13
add static
Browse files- app.py +2 -0
- src/tools/datastatics.py +38 -0
- statics_eachday.json +1 -0
app.py
CHANGED
@@ -31,6 +31,7 @@ from src.populate import get_evaluation_queue_df, get_leaderboard_df
|
|
31 |
from src.submission.submit import add_new_eval
|
32 |
from src.scripts.update_all_request_files import update_dynamic_files
|
33 |
from src.tools.collections import update_collections
|
|
|
34 |
from src.tools.plots import (
|
35 |
create_metric_plot_obj,
|
36 |
create_plot_df,
|
@@ -492,5 +493,6 @@ with demo:
|
|
492 |
scheduler = BackgroundScheduler()
|
493 |
scheduler.add_job(restart_space, "interval", seconds=1800)
|
494 |
scheduler.add_job(update_dynamic_files, "cron", minute=30) # launched every hour on the hour
|
|
|
495 |
scheduler.start()
|
496 |
demo.queue(default_concurrency_limit=40).launch()
|
|
|
31 |
from src.submission.submit import add_new_eval
|
32 |
from src.scripts.update_all_request_files import update_dynamic_files
|
33 |
from src.tools.collections import update_collections
|
34 |
+
form src.tools.data_statics import get_statics
|
35 |
from src.tools.plots import (
|
36 |
create_metric_plot_obj,
|
37 |
create_plot_df,
|
|
|
493 |
scheduler = BackgroundScheduler()
|
494 |
scheduler.add_job(restart_space, "interval", seconds=1800)
|
495 |
scheduler.add_job(update_dynamic_files, "cron", minute=30) # launched every hour on the hour
|
496 |
+
scheduler.add_job(get_statics, 'cron', hour=0, minute=30, timezone='Asia/Shanghai') # 添加定时任务,每天0:30执行一次
|
497 |
scheduler.start()
|
498 |
demo.queue(default_concurrency_limit=40).launch()
|
src/tools/datastatics.py
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import json
|
3 |
+
import datetime
|
4 |
+
from src.envs import API, EVAL_REQUESTS_PATH
|
5 |
+
|
6 |
+
def get_statics(save_path=EVAL_REQUESTS_PATH):
|
7 |
+
"""Creates the different dataframes for the evaluation queues requestes"""
|
8 |
+
entries = [entry for entry in os.listdir(save_path) if not entry.startswith(".")]
|
9 |
+
all_evals = []
|
10 |
+
|
11 |
+
for entry in entries:
|
12 |
+
if ".json" in entry:
|
13 |
+
file_path = os.path.join(save_path, entry)
|
14 |
+
with open(file_path) as fp:
|
15 |
+
data = json.load(fp)
|
16 |
+
all_evals.append(data)
|
17 |
+
elif ".md" not in entry:
|
18 |
+
sub_entries = [e for e in os.listdir(f"{save_path}/{entry}") if not e.startswith(".")]
|
19 |
+
for sub_entry in sub_entries:
|
20 |
+
file_path = os.path.join(save_path, entry, sub_entry)
|
21 |
+
with open(file_path) as fp:
|
22 |
+
data = json.load(fp)
|
23 |
+
all_evals.append(data)
|
24 |
+
finished_list = [e for e in all_evals if e["status"].startswith("FINISHED") or e["status"] == "PENDING_NEW_EVAL"]
|
25 |
+
|
26 |
+
finished = len(finished_list)
|
27 |
+
submmit = len(all_evals)
|
28 |
+
print(finished, submmit)
|
29 |
+
with open("statics_eachday.json","r") as f:
|
30 |
+
statics = json.load(f)
|
31 |
+
print(type(statics),str(datetime.datetime.now()), type(str(datetime.datetime.now())))
|
32 |
+
statics.append({"date":str(datetime.datetime.now()),"finished":finished, "submmit":submmit})
|
33 |
+
with open("statics_eachday.json","w") as f:
|
34 |
+
f.write(json.dumps(statics))
|
35 |
+
|
36 |
+
|
37 |
+
if __name__ == "__main__":
|
38 |
+
get_statics(EVAL_REQUESTS_PATH)
|
statics_eachday.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
[]
|