Download src/config.py from Suburst/NJU_Final_Transformer_Tanslation: direct link, hf CLI and curl.
- Browser
- Download file 548 Bytes
-
https://huggingface.co/spaces/Suburst/NJU_Final_Transformer_Tanslation/resolve/main/src/config.py
- Command line
-
hf download hf://spaces/Suburst/NJU_Final_Transformer_Tanslation/src/config.py
-
curl -L -o config.py https://huggingface.co/spaces/Suburst/NJU_Final_Transformer_Tanslation/resolve/main/src/config.py
548 Bytes
| import yaml | |
| from loguru import logger | |
| class Config: | |
| def __init__(self, config_path): | |
| """ | |
| 初始化 Config 类,读取指定路径的 YAML 配置文件。 | |
| :param config_path: 配置文件的路径 | |
| """ | |
| with open(config_path, 'r') as file: | |
| self.config = yaml.safe_load(file) | |
| logger.info(f"加载配置文件{self.config}") | |
| def get_config(self): | |
| """ | |
| 获取读取的配置信息。 | |
| :return: 包含配置信息的字典 | |
| """ | |
| return self.config | |