-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
26 lines (20 loc) · 833 Bytes
/
main.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
import importlib
from argparse import ArgumentParser
import sys
# lazy load modules
from training_scheduler import parse_cmd_multistage
parsers = {
"span": ("span.model", "SpanParser"),
"hrg": ("span.hrg_parser", "UdefQParser")
}
if __name__ == '__main__':
parser_name_arg_parser = ArgumentParser(sys.argv[0])
parser_name_arg_parser.add_argument("parser",
help="Parser you want to use",
choices=parsers.keys())
parser_name_args = parser_name_arg_parser.parse_args(sys.argv[1:2])
parser_name = parser_name_args.parser
module_name, class_name = parsers[parser_name]
ParserClass = getattr(importlib.import_module(module_name), class_name)
args = parse_cmd_multistage(ParserClass, sys.argv[2:])
args.func(args)