-
Notifications
You must be signed in to change notification settings - Fork 0
Prepare for v1.0.0 release #33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6527870 to
8f48254
Compare
8f48254 to
6ad06d8
Compare
Contributor
CI 概覽
快速連結
Pytest 結果
測試環境
最慢測試 Top 20
覆蓋率
覆蓋率最低的檔案 (前 10 名)
覆蓋率缺口未覆蓋的檔案列表
|
Collaborator
|
Readme 沒有改? |
- Updated README_tw.md to correct PyPI package name from `capybara_docsaid` to `capybara-docsaid` and improved installation instructions. - Enhanced the Dockerfile to streamline the installation process by directly installing the package without building a wheel, reducing complexity.
Contributor
Author
|
補上了。 |
kunkunlin1221
approved these changes
Jan 12, 2026
Collaborator
kunkunlin1221
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
1) 本次 PR 的目標(Overview)
pytest測試覆蓋率提升到 99%,並把「覆蓋率/靜態檢查/格式」變成可自動驗收的守門機制。ruff checkruff format --checkpyrightpip install .保持輕量;需要推論才安裝對應 extra)capybara/runtime.py提供 runtime/backends 的統一選擇與 auto-detect 能力ruff/pyright/coverage gate讓「程式風格、型別契約、邊界行為」能在 CI 直接被擋下,降低維運時的隱性 bug(silent failure)與環境相依問題。可驗收指令清單
(可選)安裝推論後端:
pip install -e '.[onnxruntime]'/pip install -e '.[openvino]'/pip install -e '.[torchscript]'/pip install -e '.[all]'2) 測試策略與覆蓋率(Testing & Coverage)
Box/Boxes、Keypoints/KeypointsList、Polygon/Polygons的轉換、正規化/反正規化、拼接與例外輸入。imresize比例回傳、透視變換的寬高交換邏輯。get_files、download_from_google、Timer、Tqdm的錯誤處理與邊界條件(空輸入、無效參數、串流失敗等)。draw_line退化情境(零長度/無效 gap)、mask normalization 的除零保護、色盤生成與 lazy import。tests/test_hidden_bugs_regressions.py與各模組新增測試為主,採「先寫測試重現,再修 code」避免回歸。Coverage 數字(可重現)
main@0b2c034;CPU 環境需避開 GPU-only 測試檔):python -m pytest --ignore tests/onnxruntime/test_engine_io_binding.py --cov=capybara --cov-config=.coveragerc --cov-report=termTOTAL 63%(多數核心模組覆蓋率偏低,例如capybara/vision/visualization/draw.py僅 15%)python -m pytest --cov=capybara --cov-config=.coveragerc --cov-report=term493 passed,TOTAL 99%(3419 stmts, 1 miss;主要模組多為 100%)capybara/vision/visualization/draw.py、capybara/utils/*、capybara/onnxengine/*、以及新增的capybara/runtime.py、capybara/openvinoengine/*、capybara/torchengine/*的完整測試覆蓋。3) 修復錯誤程式碼(Bug Fixes)
修復主題 1:正規化座標旗標遺失,導致視覺化/座標運算默默錯(silent failure)
(a) 原本寫法會導致的錯誤
is_normalized在convert()/copy()或 prepare helper 中被丟失)。Box/Polygon/Keypoints等結構在「正規化座標」情境(0~1)被當成「絕對座標」使用,繪圖會落在角落、裁切/座標換算錯誤但不一定拋例外。clip()先轉到 XYXY 再回傳時,模式標記可能與資料不一致(例如輸入 XYWH 卻回傳一組 XYXY 值但標成 XYWH)。(b) 重現錯誤的方法
tests/vision/visualization/test_draw.py::test_draw_box_denormalizes_normalized_boxtests/structures/test_boxes.py::test_box_convert_preserves_is_normalized_flagtests/structures/test_boxes.py::test_box_clip_preserves_box_mode_for_xywh_inputs(c) 怎麼修,以及為什麼這樣修
convert()/copy()/shift()/square()/clip()等回傳新物件時,改為保留is_normalized,避免語意被默默重置。clip()改為「先轉 XYXY 做 clipping → 再 convert 回原本box_mode」,確保資料與 mode 標記一致。prepare_keypoints/prepare_polygon/...)對已是結構物件的輸入不再重建,避免把旗標洗掉。修復主題 2:
pyproject.toml的onnxruntime-gpuextra 名稱錯誤,導致安裝失敗(a) 原本寫法會導致的錯誤
pip install -e '.[onnxruntime-gpu]'會因套件名寫成onnxruntime_gpu而失敗)。(b) 重現錯誤的方法
tests/test_hidden_bugs_regressions.py::test_pyproject_onnxruntime_gpu_extra_uses_hyphenated_package_name(c) 怎麼修,以及為什麼這樣修
onnxruntime_gpu修正為 PyPI 正確名稱onnxruntime-gpu。修復主題 3:檔案/下載工具在邊界條件下行為不正確(目錄誤入結果、下載頁面 token 解析失敗)
(a) 原本寫法會導致的錯誤
get_files(..., suffix=None)可能把「資料夾」也當成結果回傳(資料型態不符合預期)。(b) 重現錯誤的方法
tests/test_hidden_bugs_regressions.py::test_get_files_does_not_return_directories_when_suffix_nonetests/utils/test_download_from_google.py(多案例涵蓋 token / HTML form / 串流失敗)(c) 怎麼修,以及為什麼這樣修
get_files在收集時先過濾Path.is_file(),確保結果語意一致。download_from_google增強:cookie confirm token、HTML form action/hidden inputs、confirm=字串 fallback;串流例外統一包裝成可讀的RuntimeError。修復主題 4:影像/幾何處理對通道數、dtype、參數邊界處理不足
(a) 原本寫法會導致的錯誤
pad/imrotate的 constant value 可能只填到部分通道。imresize(return_scale=True)在單邊指定尺寸時回傳 scale 的分支未被驗證。(b) 重現錯誤的方法
tests/test_hidden_bugs_regressions.py::test_pad_constant_value_fills_all_channels_for_rgbatests/test_hidden_bugs_regressions.py::test_imrotate_constant_border_fills_all_channels_for_rgbatests/test_hidden_bugs_regressions.py::test_imrotate_preserves_dtype_for_float32_inputstests/vision/test_functional.py::test_pad_rejects_invalid_pad_value_type_and_invalid_image_ndimtests/vision/test_geometric.py::test_imresize_return_scale_when_only_one_dim_providedtests/vision/test_geometric.py::test_imrotate_validates_image_ndim_and_border_value_tuple_sizes(c) 怎麼修,以及為什麼這樣修
pad_value/bordervalue,並在 tuple 長度不匹配時明確 raise。修復主題 5:視覺化繪圖在字型缺失、退化輸入與 normalization 下不穩定
(a) 原本寫法會導致的錯誤
draw_text可能失敗;某些 font 物件不支援getbbox可能導致例外。draw_line在gap<=0或pt1==pt2的退化情境行為不明確。draw_mask(min_max_normalize=True)在 mask 全常數時有除零風險。(b) 重現錯誤的方法
tests/test_hidden_bugs_regressions.py::test_draw_text_falls_back_when_font_files_missingtests/vision/visualization/test_draw.py::test_draw_text_handles_fonts_without_getbboxtests/test_hidden_bugs_regressions.py::test_draw_line_handles_zero_length_and_validates_gaptests/test_hidden_bugs_regressions.py::test_draw_mask_minmax_normalize_constant_mask_is_safetests/vision/visualization/test_draw.py::test_generate_colors_and_distinct_color(c) 怎麼修,以及為什麼這樣修
load_default()fallback;getbbox失敗則安全降級(offset=0)。draw_line明確驗證gap>0,並處理零長度線段為點狀繪製。draw_mask在 denom=0 時輸出全 0 mask,避免除零。修復主題 6:推論引擎封裝缺少一致的輸入/輸出契約與可測性(並擴充 OpenVINO/TorchScript)
(a) 原本寫法會導致的錯誤
(b) 重現錯誤的方法
tests/onnxengine/test_engine_stubbed.pytests/openvinoengine/test_openvino_engine_stubbed.pytests/test_torchengine.pytests/onnxruntime/test_engine_io_binding.py在缺少 CUDA runtime 時可能不穩定(本 PR 以 stub 測試取代此類依賴)。(c) 怎麼修,以及為什麼這樣修
capybara/runtime.py的 Runtime/Backend registry 與 auto backend 策略,並提供capybara/onnxengine、capybara/openvinoengine、capybara/torchengine的一致封裝介面(run/summary/benchmark)。onnxruntime/fakeopenvino/faketorch),提高可測性與環境可重現性。4) 工具與品質門檻(Quality Gates)
pyproject.toml:加入ruff設定(lint/format)、並用 optional-dependencies 提供推論後端 extras(onnxruntime/openvino/torchscript)。pyrightconfig.json:啟用typeCheckingMode=basic,並納入capybara與tests。.coveragerc:定義 coverage 規則(排除平台/環境相依或非核心模組,讓 coverage gate 聚焦在可測且需維護的核心程式碼)。.github/workflows/ci.yml:CI 增加pyright,並將 coverage gate 設為 行覆蓋率 >= 99% 且強制執行。ruff check .ruff format --check .pyrightpython -m pytest --cov=capybara --cov-config=.coveragerc --cov-report=term.coveragercomit:capybara/cpuinfo.py、capybara/utils/system_info.py、capybara/vision/ipcam/app.pypyrightconfig.jsonexclude:capybara/cpuinfo.pybasictype checking gate;其餘核心模組已納入。5) 風險與相容性(Risk & Compatibility)
pad/imrotate/draw_line的參數檢查);以往可能「默默接受」的輸入,現在會raise ValueError/TypeError。Box/Boxes的clip/convert/copy等操作現在會保留is_normalized,並保證回傳資料與box_mode一致;若既有呼叫端依賴舊的錯誤行為,需調整。pyproject.toml為主(移除setup.py),且推論後端改為 opt-in extras;若既有流程依賴setup.py或預設就有 ORT/OpenVINO/Torch,需改用 extras 安裝。pip install -e '.[onnxruntime]'或pip install -e '.[onnxruntime-gpu]'pip install -e '.[openvino]'pip install -e '.[torchscript]'