-
Notifications
You must be signed in to change notification settings - Fork 7
/
run_yml.py
41 lines (31 loc) · 1.01 KB
/
run_yml.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
import yaml
import json
import shlex
import argparse
import subprocess
from pathlib import Path
# import supernnova.conf as conf
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="SuperNNova using yaml")
parser.add_argument("yml", type=Path, help="Yaml configuration file")
parser.add_argument(
"--mode",
choices=["data", "train_rnn", "validate_rnn", "plot_lcs"],
)
args = parser.parse_args()
config = yaml.load(open(args.yml, "r"), Loader=yaml.Loader)
cmd = f"python run.py --{args.mode} "
for k, v in config.items():
if isinstance(v, list):
cmd += f"--{k} {' '.join(v)} "
elif isinstance(v, bool):
if v is True and k not in ["bidirectional", "random_length"]:
cmd += f"--{k} "
elif isinstance(v, dict):
cmd += f"--{k} '{json.dumps(v)}' "
else:
cmd += f"--{k} {v} "
print("")
print(cmd)
print("")
subprocess.check_call(shlex.split(cmd))