-
Notifications
You must be signed in to change notification settings - Fork 7
/
run.py
54 lines (40 loc) · 1.37 KB
/
run.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
# -*- coding: utf-8 -*-
# -- stdlib --
import argparse
import logging
import dataclasses, json
# -- third party --
# -- own --
from utils import logconfig
import core.runner
import core.upload
# -- code --
log = logging.getLogger(__name__)
class EnhancedJSONEncoder(json.JSONEncoder):
def default(self, o):
if dataclasses.is_dataclass(o):
return dataclasses.asdict(o)
return super().default(o)
def save_json(results, path):
import json
with open(path, 'w') as f:
json.dump(results, f, cls=EnhancedJSONEncoder)
def main():
parser = argparse.ArgumentParser('taichi-benchmark')
parser.add_argument('--log', default='INFO')
parser.add_argument('--upload-auth', type=str, default='')
parser.add_argument('--save', type=str, default='')
parser.add_argument('--tags', type=str, default='')
options = parser.parse_args()
logconfig.init(getattr(logging, options.log))
results = core.runner.run_benchmarks()
if options.save:
log.info('Saving results to %s', options.save)
save_json(results, options.save)
if options.upload_auth:
log.info('Uploading results to server')
tags = options.tags.strip()
tags = dict(i.split("=") for i in tags.split(",")) if tags else {}
core.upload.upload_results(results, options.upload_auth, tags)
if __name__ == '__main__':
main()