33"""
44
55
6- import os.path
76import argparse
8- from collections import namedtuple
9- import yaml
10-
11- O2TunerArg = namedtuple("O2TunerArg", "option config descr")
127
138
149class O2TunerArgumentParser(argparse.ArgumentParser):
@@ -19,35 +14,39 @@ class O2TunerArgumentParser(argparse.ArgumentParser):
1914 """
2015
2116 def __init__(self):
22- self.args_normal = []
17+ # self.args_normal = []
2318 super().__init__(formatter_class=argparse.RawTextHelpFormatter)
2419 super().add_argument("-v", "--version", dest="version", default=False, action="store_true",
25- help="Print current alidock version on stdout")
20+ help="Print current o2tuner version on stdout")
21+ super().add_argument("-w", "--workdir", dest="work_dir", help="Working directory to run in",
22+ required=True)
23+ super().add_argument("-c", "--config", help="your configuration", required=True)
2624 super().add_argument("-q", "--quiet", dest="quiet", default=False,
2725 action="store_true", help="Do not print any message")
2826 super().add_argument("-d", "--debug", dest="debug", default=None,
29- action="store_true", help="Increase verbosity")
27+ action="store_true", help="Increase verbosity level")
28+ super().add_argument("-s", "--stages", nargs="*", help="Run until specified stage")
3029 super().add_argument("action", default="run",
31- nargs="?", choices=["run"], help="Run optimiser ")
32-
33- def gen_config_help(self, default_conf):
34- conf_file = os.path.join(os.getcwd(), ".o2tuner-config.yaml")
35- epilog = f"It is possible to specify the most frequently used options in a YAML " \
36- f"configuration file in your working directory\n" \
37- f"Current expected path is: {conf_file}\n" \
38- f"The following options (along with their default values) can be specified " \
39- f"(please include `---` as first line):\n---\n"
40- yaml_lines = {}
41- longest = 0
42- for opt in self.args_normal:
43- if opt.config:
44- assert opt.config in default_conf, f"option {opt.config} expected in default conf"
45- optd = {opt.config: default_conf[opt.config]}
46- yaml_lines[opt.option] = yaml.dump(
47- optd, default_flow_style=False).rstrip()
48- longest = max(longest, len(yaml_lines[opt.option]))
49- fmt = f"%%-{longest}s # same as option %%s\n"
50- for y_line in yaml_lines.items():
51- epilog += fmt % (yaml_lines[y_line], y_line)
52-
53- self.epilog = epilog
30+ nargs="?", choices=["run", "init" ], help="Actions to be performed ")
31+
32+ # def gen_config_help(self, default_conf):
33+ # conf_file = os.path.join(os.getcwd(), ".o2tuner-config.yaml")
34+ # epilog = f"It is possible to specify the most frequently used options in a YAML " \
35+ # f"configuration file in your working directory\n" \
36+ # f"Current expected path is: {conf_file}\n" \
37+ # f"The following options (along with their default values) can be specified " \
38+ # f"(please include `---` as first line):\n---\n"
39+ # yaml_lines = {}
40+ # longest = 0
41+ # for opt in self.args_normal:
42+ # if opt.config:
43+ # assert opt.config in default_conf, f"option {opt.config} expected in default conf"
44+ # optd = {opt.config: default_conf[opt.config]}
45+ # yaml_lines[opt.option] = yaml.dump(
46+ # optd, default_flow_style=False).rstrip()
47+ # longest = max(longest, len(yaml_lines[opt.option]))
48+ # fmt = f"%%-{longest}s # same as option %%s\n"
49+ # for y_line in yaml_lines.items():
50+ # epilog += fmt % (yaml_lines[y_line], y_line)
51+
52+ # self.epilog = epilog
0 commit comments