-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py
54 lines (49 loc) · 1.51 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
import argparse
import json
import logging
import sys
from experimenter.training import BasicTrainer
def setup_args():
parser = argparse.ArgumentParser()
parser.add_argument(
"--config_file",
type=str,
default=None,
required=True,
help="Configuration file to load parameters from. If other parameters are passed they\
will override whatever in config file",
)
parser.add_argument(
"--root_path",
type=str,
default=None,
required=False,
help="If provided, will override the root path",
)
parser.add_argument(
"--experiment_name",
type=str,
default=None,
required=False,
help="If provided, will override experiment name",
)
parser.add_argument(
"--logging_level",
type=int,
default=logging.INFO,
help="Level of logging according to logging package. Default is INFO",
)
return parser.parse_known_args()
if __name__ == "__main__":
args = setup_args()[0]
logging.basicConfig(stream=sys.stdout, level=args.logging_level)
logger = logging.getLogger()
logger.setLevel(args.logging_level)
args_dict = json.load(open(args.config_file, "r"))
if args.experiment_name:
args_dict["experiment_name"] = args.experiment_name
if args.root_path:
args_dict["root_path"] = args.root_path
logger.debug("Root path :{}".format(args_dict["root_path"]))
trainer = BasicTrainer(args_dict)
trainer()