MCPcopy Create free account
hub / github.com/DeepGraphLearning/graphvite / load_config

Function load_config

python/graphvite/cmd.py:82–106  ·  view source on GitHub ↗
(config_file)

Source from the content-addressed store, hash-verified

80
81
82def 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
109def new_main(args):

Callers 2

run_mainFunction · 0.85
baseline_mainFunction · 0.85

Calls 2

OptimizerMethod · 0.80
loadMethod · 0.80

Tested by

no test coverage detected