(args)
| 191 | |
| 192 | |
| 193 | def baseline_main(args): |
| 194 | config_path = get_config_path() |
| 195 | |
| 196 | configs = [] |
| 197 | for path, dirs, files in os.walk(config_path): |
| 198 | for file in files: |
| 199 | file = os.path.join(path, file) |
| 200 | match = True |
| 201 | for keyword in args.keywords: |
| 202 | result = re.search(r"[/\\_.]%s[/\\_.]" % keyword, file) |
| 203 | if not result: |
| 204 | match = False |
| 205 | break |
| 206 | if match: |
| 207 | configs.append(file) |
| 208 | if len(configs) == 0: |
| 209 | raise ValueError("Can't find a baseline with keywords: %s" % ", ".join(args.keywords)) |
| 210 | if len(configs) > 1: |
| 211 | configs = sorted(configs) |
| 212 | configs = [""] + [os.path.relpath(config, config_path) for config in configs] |
| 213 | raise ValueError("Ambiguous keywords. Candidates are:%s" % "\n ".join(configs)) |
| 214 | |
| 215 | config = configs[0] |
| 216 | print("running baseline: %s" % os.path.relpath(config, config_path)) |
| 217 | cfg = load_config(config) |
| 218 | if args.gpu is not None: |
| 219 | cfg.resource.gpus = range(args.gpu) |
| 220 | if args.cpu is not None: |
| 221 | cfg.resource.cpu_per_gpu = args.cpu |
| 222 | if args.epoch is not None: |
| 223 | cfg.train.num_epoch = args.epoch |
| 224 | |
| 225 | app = gap.Application(cfg.application, **cfg.resource) |
| 226 | app.load(**cfg.graph) |
| 227 | app.build(**cfg.build) |
| 228 | if "load" in cfg: |
| 229 | app.load_model(**cfg.load) |
| 230 | app.train(**cfg.train) |
| 231 | if args.eval and "evaluate" in cfg: |
| 232 | if isinstance(cfg.evaluate, dict): |
| 233 | cfg.evaluate = [cfg.evaluate] |
| 234 | for evaluation in cfg.evaluate: |
| 235 | app.evaluate(**evaluation) |
| 236 | if "save" in cfg: |
| 237 | app.save_model(**cfg.save) |
| 238 | |
| 239 | |
| 240 | def list_main(args): |
nothing calls this directly
no test coverage detected