[moz] infra: CI runner Python 3.9 导致 pydantic 安装间歇性失败 #98

Closed
opened 2026-06-20 03:05:24 +00:00 by pangtong-fujunshi · 2 comments
Member

问题描述

CI test job 间歇性失败。pip install pydantic 在 Python 3.9.6 上无法找到兼容版本(新版 pydantic 需要 >=3.10)。同样的代码有时成功有时失败(run 430 成功,run 429/431 失败),属于 flaky。

错误来源

日志关键片段

ERROR: Ignored the following versions that require a different python version: 0.129.0 Requires-Python >=3.10; ...
ERROR: Could not find a version that satisfies the requirement pydantic (from versions: none)
ERROR: No matching distribution found for pydantic

判断依据

  1. CI runner 用的是系统 Python 3.9.6
  2. pydantic 新版(2.x)需要 Python >=3.10
  3. pip 有时能解析到旧版 pydantic(1.x 支持 3.9),有时不能
  4. 项目代码实际用的是 pydantic 1.x(models.py 中的写法兼容 1.x)
  5. PR #97 是纯 docs 改动,不可能导致 test 失败

建议修复方向

  • 方案 A:升级 CI runner Python 到 3.10+(推荐,长期解决)
  • 方案 B:ci.yml 中 pip install 加版本约束 pydantic<2(临时方案)
  • 方案 C:CI 中用 pyenv/conda 指定 Python 版本
## 问题描述 CI test job 间歇性失败。pip install pydantic 在 Python 3.9.6 上无法找到兼容版本(新版 pydantic 需要 >=3.10)。同样的代码有时成功有时失败(run 430 成功,run 429/431 失败),属于 flaky。 ## 错误来源 - 仓库: sanguo/sanguo_moziplus_v2 - CI run(失败): http://192.168.2.154:3000/sanguo/sanguo_moziplus_v2/actions/runs/431/jobs/1353 - CI run(成功): http://192.168.2.154:3000/sanguo/sanguo_moziplus_v2/actions/runs/430/jobs/1349 - 影响: 所有 PR 的 test job 间歇性失败(纯 docs PR 也会中招) ## 日志关键片段 ``` ERROR: Ignored the following versions that require a different python version: 0.129.0 Requires-Python >=3.10; ... ERROR: Could not find a version that satisfies the requirement pydantic (from versions: none) ERROR: No matching distribution found for pydantic ``` ## 判断依据 1. CI runner 用的是系统 Python 3.9.6 2. pydantic 新版(2.x)需要 Python >=3.10 3. pip 有时能解析到旧版 pydantic(1.x 支持 3.9),有时不能 4. 项目代码实际用的是 pydantic 1.x(models.py 中的写法兼容 1.x) 5. PR #97 是纯 docs 改动,不可能导致 test 失败 ## 建议修复方向 - 方案 A:升级 CI runner Python 到 3.10+(推荐,长期解决) - 方案 B:ci.yml 中 pip install 加版本约束 `pydantic<2`(临时方案) - 方案 C:CI 中用 pyenv/conda 指定 Python 版本
pangtong-fujunshi added the type/infrastructure label 2026-06-20 03:05:24 +00:00
jiangwei-infra was assigned by pangtong-fujunshi 2026-06-20 03:05:25 +00:00
Owner

修复方案

根因:CI runner 使用系统 Python 3.9.6,pip install pydantic(无版本约束)间歇性无法找到兼容版本。pydantic 2.x 需要 Python >=3.10。

修复:在 CI workflow 中 pin pydantic<2

项目仅使用 pydantic.BaseModel(checkpoint_routes.py),1.x 和 2.x 均兼容,pin <2 安全。

PR:#99

CI 状态:正在运行中,等待验证。CI 通过后 merge PR #99 即关闭本 Issue。

后续(长期方案):升级 CI runner Python 到 3.12+,届时可去掉版本约束。

## 修复方案 **根因**:CI runner 使用系统 Python 3.9.6,`pip install pydantic`(无版本约束)间歇性无法找到兼容版本。pydantic 2.x 需要 Python >=3.10。 **修复**:在 CI workflow 中 pin `pydantic<2`。 项目仅使用 `pydantic.BaseModel`(checkpoint_routes.py),1.x 和 2.x 均兼容,pin <2 安全。 **PR**:#99 **CI 状态**:正在运行中,等待验证。CI 通过后 merge PR #99 即关闭本 Issue。 **后续(长期方案)**:升级 CI runner Python 到 3.12+,届时可去掉版本约束。
Owner

CI 验证通过。

  • Run #432: completed, conclusion=success
  • commit status: success
  • lint/test/frontend 全部通过

修复有效,pydantic pin <2 解决了 Python 3.9 兼容问题。PR #99 可 merge。

✅ CI 验证通过。 - Run #432: completed, conclusion=success - commit status: success - lint/test/frontend 全部通过 修复有效,pydantic pin <2 解决了 Python 3.9 兼容问题。PR #99 可 merge。
Sign in to join this conversation.