Check whether configuration file is valid, If anything wrong, exception will be raised. Args: cfg (str or ConfigDict): Config file path or config object. is_training: indicate if checking training related elements
(cfg: Union[str, ConfigDict], is_training=False)
| 692 | |
| 693 | |
| 694 | def check_config(cfg: Union[str, ConfigDict], is_training=False): |
| 695 | """ Check whether configuration file is valid, If anything wrong, exception will be raised. |
| 696 | |
| 697 | Args: |
| 698 | cfg (str or ConfigDict): Config file path or config object. |
| 699 | is_training: indicate if checking training related elements |
| 700 | """ |
| 701 | |
| 702 | if isinstance(cfg, str): |
| 703 | cfg = Config.from_file(cfg) |
| 704 | |
| 705 | def check_attr(attr_name, msg=''): |
| 706 | assert hasattr(cfg, attr_name), f'Attribute {attr_name} is missing from ' \ |
| 707 | f'{ModelFile.CONFIGURATION}. {msg}' |
| 708 | |
| 709 | check_attr(ConfigFields.framework) |
| 710 | check_attr(ConfigFields.task) |
| 711 | check_attr(ConfigFields.pipeline) |
| 712 | |
| 713 | if is_training: |
| 714 | check_attr(ConfigFields.model) |
| 715 | check_attr(ConfigFields.train) |
| 716 | check_attr(ConfigFields.preprocessor) |
| 717 | check_attr(ConfigFields.evaluation) |
| 718 | |
| 719 | |
| 720 | class JSONIteratorEncoder(json.JSONEncoder): |
searching dependent graphs…