| 37 | return cfg, cfg_file_path |
| 38 | '''parse''' |
| 39 | def parse(self, cfg_file_path): |
| 40 | # ext to parse method |
| 41 | ext_to_parse_method = { |
| 42 | '.py': self.parsefrompy, '.pkl': self.parsefrompkl, |
| 43 | } |
| 44 | # config ext |
| 45 | cfg_ext = os.path.splitext(cfg_file_path)[-1] |
| 46 | # assert |
| 47 | assert cfg_ext in ext_to_parse_method, f'unable to parse config with extension {cfg_ext}' |
| 48 | # parse |
| 49 | return ext_to_parse_method[cfg_ext](cfg_file_path=cfg_file_path) |
| 50 | '''save''' |
| 51 | def save(self, work_dir=''): |
| 52 | work_dir = os.path.join(work_dir, 'configs') |