settings.py 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # -*- coding: utf-8 -*-
  2. """运行时业务路径配置(向后兼容 re-export 层)。
  3. Phase 1 重构后真实配置在 config/*.yaml,经 infra/config.py 读取。
  4. 本文件保留所有原变量名,保证 run_web_server / run_preprocess_server /
  5. run_model_server / run_utils 等老代码无需改动即可运行。
  6. 重要变更:
  7. - PREPROCESS_QUEUE 拼写已修正为 "preprocess_queue1",
  8. 旧名 "preprocess_queqe1" 保留为 PREPROCESS_QUEUE_LEGACY_ALIAS,
  9. 兼容存量队列数据,将在下个版本删除。
  10. - 真实 Redis/PG 密码、IP 不再硬编码于此,走环境变量 / config/.env。
  11. 详见 ARCHITECTURE.md 第 11 章 Phase 1。
  12. """
  13. from __future__ import absolute_import
  14. import logging
  15. from BiddingKG.dl.infra import config as _config
  16. # ===== Redis 连接参数(原 settings.py 顶部)=====
  17. _main = _config.redis_main_config()
  18. REDIS_HOST = _main.get("host", "127.0.0.1")
  19. REDIS_PORT = int(_main.get("port", 6379))
  20. REDIS_DB = int(_main.get("db", 12))
  21. REDIS_PASS = _main.get("password", "")
  22. # ===== Redis 队列名 =====
  23. _q = _config.redis_queue_names()
  24. CONTENT_QUEUE = _q.get("content", "content_queue1")
  25. PREPROCESS_QUEUE = _q.get("preprocess", "preprocess_queue1") # 修正拼写
  26. PREPROCESS_QUEUE_LEGACY_ALIAS = _q.get("preprocess_legacy_alias", "preprocess_queqe1") # 兼容旧名
  27. ERROR_QUEUE = _q.get("error", "error_queue")
  28. TIMEOUT_QUEUE = _q.get("timeout", "timeout_queue")
  29. # ===== 消费者参数 =====
  30. _c = _config.redis_consumer_params()
  31. BATCH_SIZE = int(_c.get("batch_size", 2))
  32. SERVER_SLEEP = float(_c.get("server_sleep", 0.002))
  33. CLIENT_SLEEP = float(_c.get("client_sleep", 0.002))
  34. TIME_OUT = int(_c.get("timeout", 20))
  35. # ===== 日志配置 =====
  36. _log = _config.logging_settings()
  37. LOG_FORMAT = _log.get("format", "%(asctime)s - %(levelname)s - %(message)s")
  38. DATE_FORMAT = _log.get("date_format", "%m/%d/%Y %H:%M:%S %p")
  39. _level_name = str(_log.get("level", "INFO")).upper()
  40. LOG_LEVEL = getattr(logging, _level_name, logging.INFO)
  41. LOG_FILE = _log.get("file", "logs/model_server.log")
  42. # ===== 模型输入 shape =====
  43. MODEL_ROLE_INPUT_SHAPE = _config.model_input_shape("role")
  44. MODEL_MONEY_INPUT_SHAPE = _config.model_input_shape("money")
  45. MODEL_PERSON_INPUT_SHAPE = _config.model_input_shape("person")