-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettings.py
More file actions
36 lines (28 loc) · 1.25 KB
/
settings.py
File metadata and controls
36 lines (28 loc) · 1.25 KB
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
30
31
32
33
34
35
36
import json
from pathlib import Path
class Settings:
def __init__(self, dataset_name:str, llm_model:str=None, emb_model: str=None, configs_path: str=None):
# load configs from file
if configs_path is None:
self.configs_path = Path(__file__).parent / "configs.json"
else:
self.configs_path = Path(configs_path)
self.dataset_name = dataset_name
# read file
with open(self.configs_path, "r") as json_file:
configs = json.load(json_file)
print(f"Loaded configs from {self.configs_path}.")
# load dataset specific configs
data_specific_configs = configs[dataset_name]
self.configs = configs["general"]
self.configs.update(data_specific_configs)
self.configs["llm"] = configs["llm"]
# replace default settings (from config file) by method arguments
if emb_model is not None:
self.configs["emb_model"] = emb_model
if llm_model is not None:
self.configs["llm"]["llm_model"] = llm_model
def get(self, config_name: str):
return self.configs[config_name]
def edge_type2str(self, key: str) -> str:
return self.configs["edge_type2str"][key]