Showing
4 changed files
with
11 additions
and
34 deletions
| @@ -3,7 +3,7 @@ app_version: "1.0.0" | @@ -3,7 +3,7 @@ app_version: "1.0.0" | ||
| 3 | 3 | ||
| 4 | match_by_time_threshold: 30 # 通过时间匹配进球事件的阈值(秒) | 4 | match_by_time_threshold: 30 # 通过时间匹配进球事件的阈值(秒) |
| 5 | 5 | ||
| 6 | -kafka_servers: 192.168.0.14:9092 | 6 | +#kafka_servers: 192.168.0.14:9092 |
| 7 | kafka_username: | 7 | kafka_username: |
| 8 | kafka_password: | 8 | kafka_password: |
| 9 | 9 |
| 1 | -import os | ||
| 2 | -from pathlib import Path | ||
| 3 | -from logging import getLogger | ||
| 4 | - | ||
| 5 | from aabd.base.cfg_loader import load_yaml_by_file_with_env | 1 | from aabd.base.cfg_loader import load_yaml_by_file_with_env |
| 6 | from aabd.base.enhance_dict import EnhanceDict, read_prefixed_env_vars | 2 | from aabd.base.enhance_dict import EnhanceDict, read_prefixed_env_vars |
| 3 | +from pathlib import Path | ||
| 4 | +from logging import getLogger | ||
| 7 | 5 | ||
| 8 | logger = getLogger(__name__) | 6 | logger = getLogger(__name__) |
| 9 | cfg_dir = Path(__file__).parent.absolute() / 'cfg' | 7 | cfg_dir = Path(__file__).parent.absolute() / 'cfg' |
| 10 | - | ||
| 11 | -# 加载基础配置 | ||
| 12 | -base_config = load_yaml_by_file_with_env((cfg_dir / 'config.yaml').as_posix()) | ||
| 13 | - | ||
| 14 | -# 根据 ENV 环境变量加载环境特定配置并合并(如 config.dev.yaml / config.prod.yaml) | ||
| 15 | -env = os.getenv('ENV', 'dev') | ||
| 16 | -env_file = cfg_dir / f'config.{env}.yaml' | ||
| 17 | -if env_file.exists(): | ||
| 18 | - env_config = load_yaml_by_file_with_env(env_file.as_posix()) | ||
| 19 | - if isinstance(base_config, dict) and isinstance(env_config, dict): | ||
| 20 | - for key, value in env_config.items(): | ||
| 21 | - if key in base_config and isinstance(base_config[key], dict) and isinstance(value, dict): | ||
| 22 | - base_config[key].update(value) | ||
| 23 | - else: | ||
| 24 | - base_config[key] = value | ||
| 25 | - logger.info(f"已加载环境配置: {env_file.name}") | ||
| 26 | - | ||
| 27 | -settings = EnhanceDict(base_config) | ||
| 28 | -settings.update(read_prefixed_env_vars('FRM_')) | 8 | +settings = EnhanceDict(load_yaml_by_file_with_env((cfg_dir / 'config.yaml').as_posix())) |
| 9 | +settings.update(read_prefixed_env_vars('EMB_')) | ||
| 29 | 10 | ||
| 30 | logger.info(f'Settings: {settings}') | 11 | logger.info(f'Settings: {settings}') |
| @@ -76,16 +76,11 @@ import json | @@ -76,16 +76,11 @@ import json | ||
| 76 | import os | 76 | import os |
| 77 | from pathlib import Path | 77 | from pathlib import Path |
| 78 | 78 | ||
| 79 | -try: | ||
| 80 | - from .llm_image import Video2Frame, frames2content | ||
| 81 | - from ..util.football_replay_match_live import FootballReplayMatchLive | ||
| 82 | - from config import settings | ||
| 83 | -except ImportError: | ||
| 84 | - import sys | ||
| 85 | - sys.path.insert(0, str(Path(__file__).parent.parent)) | ||
| 86 | - from core.llm_image import Video2Frame, frames2content | ||
| 87 | - from util.football_replay_match_live import FootballReplayMatchLive | ||
| 88 | - from config import settings | 79 | + |
| 80 | +from .llm_image import Video2Frame | ||
| 81 | +from ..util.football_replay_match_live import FootballReplayMatchLive | ||
| 82 | +from ..config import settings | ||
| 83 | + | ||
| 89 | 84 | ||
| 90 | 85 | ||
| 91 | # 从配置中读取参数(配置项需在 config.yaml 或对应环境配置中定义) | 86 | # 从配置中读取参数(配置项需在 config.yaml 或对应环境配置中定义) |
-
Please register or login to post a comment