forked from tddschn/easygraph-bench
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdb_fill_bench_results_from_csv.py
executable file
·66 lines (54 loc) · 1.71 KB
/
db_fill_bench_results_from_csv.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env python3
"""
Author : Xinyuan Chen <[email protected]>
Date : 2022-09-25
Purpose: Fill graph info to the sqlite3 db
"""
import argparse
from datetime import datetime
from pathlib import Path
from utils_db import insert_bench_results
from utils_other import tool_str_to_tool_and_n_workers
from config import bench_results_db_path, tool_name_mapping
import sqlite3, csv
def get_args():
"""Get command-line arguments"""
parser = argparse.ArgumentParser(
description='Fill graph info to the sqlite3 db',
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
)
parser.add_argument(
'--db-path',
metavar='PATH',
type=Path,
help='Path to the database',
default=bench_results_db_path,
)
parser.add_argument(
'csv_path',
metavar='PATH',
type=Path,
help='Path to csv file',
)
return parser.parse_args()
def main():
"""Make a jazz noise here"""
args = get_args()
csv_path = args.csv_path
with sqlite3.connect(args.db_path) as conn:
with csv_path.open() as f:
reader = csv.DictReader(f)
for row in reader:
tool_str = row['tool']
tool, n_workers = tool_str_to_tool_and_n_workers(tool_str)
insert_bench_results(
conn,
dataset=row.get('dataset', csv_path.stem),
method=row['method'],
tool=tool,
average_time=float(row['avg time']),
timestamp=datetime.now(),
n_workers=int(n_workers) if n_workers else 1,
)
if __name__ == '__main__':
main()