From a13b79092637dac694d93f4e0e9b2190ad7e489d Mon Sep 17 00:00:00 2001 From: Xuwznln <18435084+Xuwznln@users.noreply.github.com> Date: Wed, 19 Nov 2025 14:22:58 +0800 Subject: [PATCH] Revert "feat(main): enhance argument parsing for addr and port with priority handling" This reverts commit 7cc2fe036f02e3193318dc0a91e2c980f57f0b22. --- unilabos/app/main.py | 48 ++++++-------------------------------------- 1 file changed, 6 insertions(+), 42 deletions(-) diff --git a/unilabos/app/main.py b/unilabos/app/main.py index 7ef48490..ad32612d 100644 --- a/unilabos/app/main.py +++ b/unilabos/app/main.py @@ -105,7 +105,7 @@ def parse_args(): parser.add_argument( "--port", type=int, - default=None, + default=8002, help="Port for web service information page", ) parser.add_argument( @@ -139,7 +139,7 @@ def parse_args(): parser.add_argument( "--addr", type=str, - default=None, + default="https://uni-lab.bohrium.com/api/v1", help="Laboratory backend address", ) parser.add_argument( @@ -220,53 +220,17 @@ def main(): logger.info(f"Log level set to '{BasicConfig.log_level}' from config file.") configure_logger(loglevel=BasicConfig.log_level) - # 选择地址优先级:命令行 > 配置文件 > 默认线上 - addr_cli = args_dict.get("addr", None) - addr_cfg = getattr(BasicConfig, "addr", None) - effective_addr = addr_cli if (addr_cli not in (None, "")) else addr_cfg - - if effective_addr == "test": + if args_dict["addr"] == "test": print_status("使用测试环境地址", "info") HTTPConfig.remote_addr = "https://uni-lab.test.bohrium.com/api/v1" - elif effective_addr == "uat": + elif args_dict["addr"] == "uat": print_status("使用uat环境地址", "info") HTTPConfig.remote_addr = "https://uni-lab.uat.bohrium.com/api/v1" - elif effective_addr == "local": + elif args_dict["addr"] == "local": print_status("使用本地环境地址", "info") HTTPConfig.remote_addr = "http://127.0.0.1:48197/api/v1" - elif effective_addr: - HTTPConfig.remote_addr = effective_addr - print_status(f"使用配置/命令行提供的自定义地址: {effective_addr}", "info") else: - # 默认地址 - HTTPConfig.remote_addr = "https://uni-lab.bohrium.com/api/v1" - print_status("未提供地址,使用默认线上地址", "info") - - # 选择端口优先级:命令行 > 配置文件 > 默认 8002 - port_cli = args_dict.get("port", None) - port_cfg = getattr(BasicConfig, "port", None) if hasattr(BasicConfig, "port") else None - effective_port = port_cli if (port_cli is not None) else (port_cfg if (port_cfg is not None) else 8002) - args_dict["port"] = effective_port - if port_cli is not None: - print_status(f"使用命令行端口 {effective_port}", "info") - elif port_cfg is not None: - print_status(f"使用配置文件端口 {effective_port}", "info") - else: - print_status(f"未提供端口,使用默认端口 {effective_port}", "info") - - # 选择是否打开浏览器:命令行(是否包含 --disable_browser) > 配置文件 > 默认 False - disable_browser_cli = "--disable_browser" in sys.argv - if disable_browser_cli: - args_dict["disable_browser"] = True - print_status("使用命令行设置:禁用浏览器", "info") - else: - disable_cfg = getattr(BasicConfig, "disable_browser", None) - if isinstance(disable_cfg, bool): - args_dict["disable_browser"] = disable_cfg - print_status(f"使用配置文件设置:disable_browser={disable_cfg}", "info") - else: - args_dict["disable_browser"] = False - print_status("未提供 disable_browser,默认开启浏览器", "info") + HTTPConfig.remote_addr = args_dict.get("addr", "") # 设置BasicConfig参数 if args_dict.get("ak", ""):