"""Clean old YAML configs. The old config is not exactly the same as the current one. There might be extra keys or missing keys. To make them compatible with the current one, we use the following script to merge and reformat the old `config.yml`. Please note that the configs are just used for reference and is not intended to be used as input files for new training runs. """ from pathlib import Path from deephall.config import Config from omegaconf import OmegaConf def clean_yml(yml_file): cfg = OmegaConf.merge(Config(), Config.from_dict(OmegaConf.load(yml_file))) if cfg.log.restore_path is not None: cfg.log.restore_path = ".." cfg.log.save_path = "." return OmegaConf.to_yaml(cfg) for yml_file in Path("data").glob("**/config.yml"): yml = clean_yml(yml_file) with yml_file.open("w") as f: f.write(yml)