()
| 175 | |
| 176 | |
| 177 | def main(): |
| 178 | args = parse_args() |
| 179 | cfg = Config.fromfile(args.config) |
| 180 | # cfg.models = |
| 181 | model2cfg = parse_model_cfg(cfg.models) if 'models' in cfg else { |
| 182 | 'None': None |
| 183 | } |
| 184 | if 'datasets' in cfg: |
| 185 | dataset2cfg = parse_dataset_cfg(cfg.datasets) |
| 186 | else: |
| 187 | dataset2cfg = {} |
| 188 | for key in cfg.keys(): |
| 189 | if key.endswith('_datasets'): |
| 190 | dataset2cfg.update(parse_dataset_cfg(cfg[key])) |
| 191 | |
| 192 | if args.pattern is not None: |
| 193 | matches = fnmatch.filter(dataset2cfg, args.pattern) |
| 194 | if len(matches) == 0: |
| 195 | raise ValueError( |
| 196 | 'No dataset match the pattern. Please select from: \n' + |
| 197 | '\n'.join(dataset2cfg.keys())) |
| 198 | dataset2cfg = {k: dataset2cfg[k] for k in matches} |
| 199 | |
| 200 | if not args.all: |
| 201 | if not args.non_interactive: |
| 202 | model, dataset = Menu( |
| 203 | [list(model2cfg.keys()), |
| 204 | list(dataset2cfg.keys())], [ |
| 205 | f'Please make a selection of {s}:' |
| 206 | for s in ['model', 'dataset'] |
| 207 | ]).run() |
| 208 | else: |
| 209 | model = list(model2cfg.keys())[0] |
| 210 | dataset = list(dataset2cfg.keys())[0] |
| 211 | model_cfg = model2cfg[model] |
| 212 | dataset_cfg = dataset2cfg[dataset] |
| 213 | print_prompts(model_cfg, dataset_cfg, args.count) |
| 214 | else: |
| 215 | for model_abbr, model_cfg in model2cfg.items(): |
| 216 | for dataset_abbr, dataset_cfg in dataset2cfg.items(): |
| 217 | print('=' * 64, '[BEGIN]', '=' * 64) |
| 218 | print(f'[MODEL]: {model_abbr}') |
| 219 | print(f'[DATASET]: {dataset_abbr}') |
| 220 | print('---') |
| 221 | print_prompts(model_cfg, dataset_cfg, args.count) |
| 222 | print('=' * 65, '[END]', '=' * 65) |
| 223 | print() |
| 224 | |
| 225 | |
| 226 | if __name__ == '__main__': |
no test coverage detected