-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathlaunch.py
More file actions
30 lines (24 loc) · 851 Bytes
/
launch.py
File metadata and controls
30 lines (24 loc) · 851 Bytes
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
import os
from os.path import join, exists
import json
import argparse
import pdb
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument('name', type=str, default='',
help='configuration name defined in the checkpoint')
parser.add_argument('--path', type=str, default='configs.json',
help='path to the configuration file')
args = parser.parse_args()
return args
def execute():
args = parse_args()
assert exists(args.path), 'configuration file does not exist'
with open(args.path, 'r') as fp:
config = json.load(fp)
assert args.name in config, 'config name does not exist'
cfg = config[args.name]
cmd = ' '.join([' '.join([k, v]) for k, v in cfg.items()])
os.system(cmd)
if __name__ == '__main__':
execute()