Skip to content

treat negative priority for data providers as disabling - #1230

Closed
littlebirds wants to merge 1 commit into
ZhuLinsen:mainfrom
littlebirds:main
Closed

treat negative priority for data providers as disabling#1230
littlebirds wants to merge 1 commit into
ZhuLinsen:mainfrom
littlebirds:main

Conversation

@littlebirds

Copy link
Copy Markdown

PR Type

  • fix
  • [ x] feat
  • refactor
  • docs
  • chore
  • test

Background And Problem

请描述当前问题、影响范围与触发场景。

  • 在分析港股行情的时候,默认优先使用的数据源经常拿到错误的数据,比如1211.HK(比亚迪),导致完全错误的结论. 配置中需要能关闭这些数据源确保可靠性

Scope Of Change

请列出本 PR 修改的模块和文件范围。

  • data_provider/base.py, env.exmaple

Issue Link

必须填写以下之一 / Fill in one of:

  • Fixes #<issue_number>
  • Refs #<issue_number>
  • 无 Issue 时说明原因与验收标准 / If no issue, explain the motivation and acceptance criteria
    默认的数据源优先级对港股会使用错误的行情数据,需要能配置关闭

Verification Commands And Results

请填写你实际执行过的命令和关键结果(不要只写"已测试")。
(EN) Paste the commands you actually ran and their key output (don't just write "tested"):

# example
./scripts/ci_gate.sh
python -m pytest -m "not network"

关键输出/结论 / Key output & conclusion:

Compatibility And Risk

请说明兼容性影响、潜在风险(如无请写 None)。

  • 原来-1是最优先级别,现在变成了禁止使用,但对正的优先级排序没有影响
  • 若本 PR 修改第三方模型 / API 的兼容语义、请求参数、路由前缀或 provider fallback,请提供官方来源链接或公告,并说明这是长期约束、当前运行时约束还是临时兼容处理。
    (EN) If this PR changes third-party model/API compatibility, request parameters, routing prefixes, or provider fallback behavior, include an official source link or announcement and clarify whether the rule is permanent, runtime-specific, or a temporary compatibility workaround.)
  • 若本 PR 依赖特定运行时 / 锁定依赖窗口(例如 LiteLLM 版本范围、OpenAI-compatible 路由、YAML alias 行为),请写明当前验证过的兼容范围与覆盖路径。
    (EN) If this PR depends on a specific runtime or pinned dependency window (for example a LiteLLM version range, OpenAI-compatible routing, or YAML alias behavior), state the compatibility window you verified and which code paths were covered.)
  • 若本 PR 触及运行时配置保存、清理、迁移或回填逻辑,请明确说明旧配置是否会被自动改写、清空、迁移或保持不变,以及用户如何恢复原行为。
    (EN) If this PR touches runtime config save/cleanup/migration/backfill logic, explicitly describe whether existing config is rewritten, cleared, migrated, or left intact, and how users can restore the previous behavior.)

Rollback Plan

请至少写一句可执行的回滚方案(必填)。
(EN) Provide at least one actionable rollback step (required).

  • 如果是兼容性修复,默认应写出最小回滚方式(例如 revert this PR),并说明是否需要额外回滚配置或数据迁移。
    (EN) For compatibility fixes, include the minimal rollback path (for example revert this PR) and whether any additional config or data rollback is required.)

EXTRACT_PROMPT Change (if applicable)

若本 PR 修改了 src/services/image_stock_extractor.py 中的 EXTRACT_PROMPT,请在此处粘贴完整变更后的 prompt。
If this PR changes EXTRACT_PROMPT in src/services/image_stock_extractor.py, paste the full updated prompt here:

展开 / Expand: Full EXTRACT_PROMPT
(paste full prompt here)

Checklist

  • 本 PR 有明确动机和业务价值 / This PR has a clear motivation and value
  • 已提供可复现的验证命令与结果 / Reproducible verification commands and results are included
  • 已评估兼容性与风险 / Compatibility and risk have been assessed
  • 已提供回滚方案 / A rollback plan is provided
  • 若涉及用户可见变更,已同步更新相关文档与 docs/CHANGELOG.mdREADME.md 仅在首页级信息变化时更新,细节优先写入 docs/*.md / If user-visible changes are included, relevant docs and docs/CHANGELOG.md are updated; README.md is updated only for homepage-level changes, with details kept in docs/*.md

@littlebirds
littlebirds requested a review from ZhuLinsen as a code owner May 8, 2026 11:33
@github-actions github-actions Bot added data-source documentation Improvements or additions to documentation size/S labels May 8, 2026
@github-actions

github-actions Bot commented May 8, 2026

Copy link
Copy Markdown

🤖 自动审查报告

项目 结果
📊 变更文件 4 个
➕ 新增行数 25 行
➖ 删除行数 12 行
🔍 静态检查 ✅ 通过
🧠 AI 审查 ✅ 已完成

📁 修改的文件

  • 📝 .env.example (+7/-0)
  • 📝 data_provider/base.py (+13/-9)
  • 📝 data_provider/tushare_fetcher.py (+4/-3)
  • 📝 docs/CHANGELOG.md (+1/-0)

🧠 AI 代码审查意见

结论: Ready to Merge

结构化审查结果

  • 必要性: 通过。本 PR 解决了港股行情分析中,默认数据源可能返回错误数据导致结论失真的问题,允许用户通过配置关闭不可靠的数据源,具有明确的业务价值。
  • 关联性: 通过。虽然没有关联到具体的 Issue ID,但 PR 描述中清晰地说明了无 Issue 的原因、问题背景和验收标准,符合要求。
  • 类型: 建议类型为 feat。PR 引入了新的功能(通过负优先级禁用数据源),此类型选择是准确的。
  • 描述完整性: 基本完整
    • 背景、问题、兼容性与风险、回滚方案均已详细描述。
    • "Scope Of Change" 中列出了 env.exmaple,但实际代码变更未包含此文件;实际变更还包括 data_provider/tushare_fetcher.pydocs/CHANGELOG.md,这在"修改文件列表"中已正确体现,故影响不大。
    • “Verification Commands And Results” 提供了命令,但关键输出和结论不够具体,未提供实际运行结果。
    • 未说明 ./scripts/ci_gate.sh 的执行情况。
  • 风险级别: 。PR 明确了负优先级的新含义,并解释了对现有优先级排序(正数优先级)无影响。Tushare 的动态提权从 -1 调整到 0,也通过 stable sort 保证了其优先于 efinance,兼容性考虑周全。

必改项 (0 条)

无。

建议项 (2 条)

  1. 验证结果具体化:建议在未来的 PR 中,对于“Verification Commands And Results”,提供更具体的命令执行输出或截图,而不仅仅是文字结论,以增强验证的可信度。
  2. ci_gate.sh 执行说明:对于 Python 后端改动,建议在 PR 描述中补充说明 ./scripts/ci_gate.sh 是否已在本地执行,以及执行结果,以确保更全面的本地测试覆盖。

💡 提示: 请确保代码已通过本地测试,并遵循项目代码规范。

@littlebirds littlebirds closed this May 8, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 50c5afef7e

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

# Token 配置且 API 初始化成功,提升为最高优先级(与 efinance 同级,
# 通过 stable sort 顺序保证 Tushare 在前)
logger.info("✅ 检测到 TUSHARE_TOKEN 且 API 初始化成功,Tushare 数据源优先级提升为最高 (Priority 0)")
return 0

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Respect explicit TUSHARE_PRIORITY disable setting

When TUSHARE_TOKEN is present, _determine_priority() now unconditionally returns 0, so an explicit TUSHARE_PRIORITY=-1 is ignored and the fetcher remains active. This breaks the new contract introduced in this change (negative priority = disabled) and means users cannot actually disable Tushare in token-enabled environments, even though .env.example now documents that they can.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

data-source documentation Improvements or additions to documentation size/S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant