Skip to content

正本清源,辞归本宗 · Correct GitHub language detection and drop orphan script#25

Merged
eric8810 merged 1 commit into
mainfrom
chore/linguist-detection
Jul 21, 2026
Merged

正本清源,辞归本宗 · Correct GitHub language detection and drop orphan script#25
eric8810 merged 1 commit into
mainfrom
chore/linguist-detection

Conversation

@eric8810

Copy link
Copy Markdown
Contributor

问题

GitHub 把本仓库识别为 Python 项目,但 light-ocr 的核心是 C++17 OCR 引擎。根因是 .gitattributes 缺少 Linguist 配置:仓库内 Python 工具链代码(14776 行)行数压过了 C++(12308 行),而 Linguist 默认全部计入。

改动

1. .gitattributes — 根治语言误识别(核心)

tools/**        linguist-detectable=false
oracle/**       linguist-detectable=false
tests/python/** linguist-detectable=false
corpus/**       linguist-detectable=false

这些目录是 CI 的发布/验证/测试工具链,不是产品的实现语言。代码留在仓库、CI 照跑,Linguist 只是不再把它们计入语言占比。合并到默认分支后 GitHub 会重新统计,项目将正确显示为 C++。

2. 删除 oracle/generate_smoke_corpus.py(65 行)

经全仓 grep + Python import 复核确认零引用的孤儿脚本。其输出与 corpus/generate_corpus.py 重复,且该 fixture 的 provenance 记录的 generator 是后者而非本脚本。

3. 新增 docs/python-asset-review.md

全部 60 个 Python 文件的完整盘点:每文件职责、行数、CI 引用证据、精简评估。

关键复核结论

初版分析曾判定 tools/webgpu/qualify.py(1235 行)和 tools/apple/ 8 个 gate(1413 行)为"可归档"。import 复核推翻该结论

文件 import 证据
tools/webgpu/qualify.py tests/python/test_webgpu_qualification.py:18from tools.webgpu import qualify
tools/apple/ 4 个 gate tests/python/test_apple_qualification.py:9-15from tools.apple import accept_qualification, collect_qualification, fallback_gate, package_bundle, performance_gate

这些测试经 core.yml:108unittest discover 在 CI 中运行,其 import 即真实引用——归档会立即 ImportError 破坏 CI。文档已记录此方法论教训:判断 CI 引用不能只 grep workflow yml,必须同时检查测试文件的 import 语句。

验证

  • git status 干净,仅本次三处改动
  • 未触及任何 CI workflow / CMakeLists / package.json
  • 删除的脚本经全仓 grep(含 .py 文件 import 语句)确认零引用

不在本 PR 范围

  • tools/common/ 去重重构:存在双重 import 模式(python tools/x.py 直接执行 vs 测试 import),需逐文件处理 try/except 兜底;实际重复仅 ~100-150 行,且已被本 PR 的 gitattributes 排除出统计,风险/收益不划算,留作独立 PR。

…script

Add linguist-detectable=false overrides in .gitattributes for tools/,
oracle/, tests/python/, and corpus/ so GitHub correctly identifies the
repository as C++ instead of Python. The code stays in-repo and CI runs
it unchanged.

Drop oracle/generate_smoke_corpus.py (65 lines): orphan script with zero
references across workflows, CMake, and Python imports; its output duplicates
corpus/generate_corpus.py which is the recorded provenance generator.

Add docs/python-asset-review.md: full inventory of all 60 Python files
(14776 lines) with per-file roles, CI reference evidence, and a
corrected pruning assessment. Import review overturned the initial
'archivable' verdict for tools/webgpu/qualify.py and the tools/apple/
gate group — both are imported by CI-active unit tests.
@eric8810
eric8810 merged commit 159fbcf into main Jul 21, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant