(config_file)
| 80 | |
| 81 | |
| 82 | def load_config(config_file): |
| 83 | |
| 84 | def get_dataset(x): |
| 85 | if not isinstance(x, str): |
| 86 | return x |
| 87 | result = re.match("<(\w+)\.(\w+)>", x) |
| 88 | if result: |
| 89 | dataset, key = result.groups() |
| 90 | dataset = getattr(gv.dataset, dataset) |
| 91 | file_name = getattr(dataset, key) |
| 92 | return file_name |
| 93 | else: |
| 94 | return x |
| 95 | |
| 96 | with open(config_file, "r") as fin: |
| 97 | cfg = EasyDict(yaml.safe_load(fin)) |
| 98 | cfg = gv.util.recursive_map(cfg, lambda x: gv.auto if x == "auto" else x) |
| 99 | cfg = gv.util.recursive_map(cfg, get_dataset) |
| 100 | if "optimizer" in cfg.build: |
| 101 | cfg.build.optimizer = gv.optimizer.Optimizer(**cfg.build.optimizer) |
| 102 | if "vectors" in cfg.graph: |
| 103 | if isinstance(cfg.graph.vectors, str) and cfg.graph.vectors.endswith(".npy"): |
| 104 | cfg.graph.vectors = np.load(cfg.graph.vectors) |
| 105 | |
| 106 | return cfg |
| 107 | |
| 108 | |
| 109 | def new_main(args): |
no test coverage detected