feat: 支持env设置config

This commit is contained in:
wznln
2025-05-01 14:52:50 +08:00
parent 9d2bfec1dd
commit 752442cb37
2 changed files with 61 additions and 6 deletions

View File

@@ -12,7 +12,7 @@ ilabos_dir = os.path.dirname(os.path.dirname(current_dir))
if ilabos_dir not in sys.path:
sys.path.append(ilabos_dir)
from unilabos.config.config import load_config, BasicConfig
from unilabos.config.config import load_config, BasicConfig, _update_config_from_env
from unilabos.utils.banner_print import print_status, print_unilab_banner
@@ -80,8 +80,10 @@ def main():
args = parse_args()
args_dict = vars(args)
# 加载配置文件 - 这里保持最先加载配置的逻辑
# 加载配置文件优先加载config然后从env读取
config_path = args_dict.get("config")
if config_path is None:
config_path = os.environ.get("UNILABOS.BASICCONFIG.CONFIG_PATH", None)
if config_path:
if not os.path.exists(config_path):
print_status(f"配置文件 {config_path} 不存在", "error")