-
Notifications
You must be signed in to change notification settings - Fork 0
/
leaderboard.py
37 lines (32 loc) · 1.33 KB
/
leaderboard.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from datetime import datetime
import csv
import os
import hashlib
def filehash(filename):
with open(filename,"rb") as f:
bytes = f.read() # read entire file as bytes
readable_hash = hashlib.sha256(bytes).hexdigest();
return readable_hash
def leaderboard(agent, env, team, mean, std, hash_url, hash_file, file = "leaderboard.csv"):
row_contents = {"agent": agent,
"env": env,
"team": team,
"mean": mean,
"std": std,
"hash_url": hash_url,
"hash_file": hash_file,
"date": datetime.now()}
has_header = os.path.exists(file)
with open(file, 'a+') as stream:
writer = csv.DictWriter(stream,
fieldnames = ["agent",
"env",
"team",
"mean",
"std",
"hash_url",
"hash_file",
"date"])
if(not has_header):
writer.writeheader()
writer.writerow(row_contents)