lixuejing
add log
21a006c
import os
import json
import datetime
from src.envs import API, EVAL_REQUESTS_PATH
def get_statics(save_path=EVAL_REQUESTS_PATH):
"""Creates the different dataframes for the evaluation queues requestes"""
entries = [entry for entry in os.listdir(save_path) if not entry.startswith(".")]
all_evals = []
for entry in entries:
print("get_statics", entry)
if ".json" in entry:
file_path = os.path.join(save_path, entry)
with open(file_path) as fp:
data = json.load(fp)
all_evals.append(data)
elif ".md" not in entry:
sub_entries = [e for e in os.listdir(f"{save_path}/{entry}") if not e.startswith(".")]
for sub_entry in sub_entries:
file_path = os.path.join(save_path, entry, sub_entry)
with open(file_path) as fp:
data = json.load(fp)
all_evals.append(data)
finished_list = [e for e in all_evals if e["status"].startswith("FINISHED") or e["status"] == "PENDING_NEW_EVAL"]
finished = len(finished_list)
submmit = len(all_evals)
print("get_stativs",finished, submmit)
with open("statics_eachday.json","r") as f:
statics = json.load(f)
print("get_statics",type(statics),str(datetime.datetime.now()), type(str(datetime.datetime.now())))
statics.append({"date":str(datetime.datetime.now()),"finished":finished, "submmit":submmit})
with open("statics_eachday.json","w") as f:
f.write(json.dumps(statics))
if __name__ == "__main__":
get_statics(EVAL_REQUESTS_PATH)