Load the config file, which is a dictionary of: var_name -> Dict[key, val]. Each of the key in var_name will replace the current value of var_name.
(self, filename: str = None)
| 537 | self.finish_procedure() |
| 538 | |
| 539 | def load_options(self, filename: str = None): |
| 540 | """ |
| 541 | Load the config file, which is a dictionary of: var_name -> Dict[key, val]. |
| 542 | Each of the key in var_name will replace the current value of var_name. |
| 543 | """ |
| 544 | |
| 545 | if filename is None: |
| 546 | self.options = dict() |
| 547 | return self.options |
| 548 | |
| 549 | # parse the config file |
| 550 | options = read_config_file(filename=filename) |
| 551 | |
| 552 | # replace |
| 553 | for var_name in options: |
| 554 | info = getattr(self, var_name, None) |
| 555 | |
| 556 | if info is None: |
| 557 | setattr(self, var_name, options[var_name]) |
| 558 | # if isinstance(options[var_name], dict): |
| 559 | # info = dict() |
| 560 | # for key, val in options[var_name].items(): |
| 561 | # info[key] = val |
| 562 | # setattr(self, var_name, info) |
| 563 | # else: |
| 564 | # setattr(self, var_name, options[var_name]) |
| 565 | else: |
| 566 | if isinstance(info, T.MutableMapping): |
| 567 | assert isinstance(options[var_name], T.MutableMapping), f"{var_name}, {type(options[var_name])}" |
| 568 | recursive_dict_update(tgt_dict=info, src_dict=options[var_name]) |
| 569 | # for key, val in options[var_name].items(): |
| 570 | # info[key] = val |
| 571 | else: |
| 572 | setattr(self, var_name, options[var_name]) |
| 573 | |
| 574 | self.options = options |
| 575 | return self.options |
| 576 | |
| 577 | def _create_folders(self, root_dir: str, exp_tag: str, exp_tag_first: bool): |
| 578 | """ |
no test coverage detected