File size: 858 Bytes
2267d4f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"""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)