test: Add unit test coverage for hardware_detect utility

オープン 初心者向け
#1,786 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 3 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
79/100
issue の種類
機能追加
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
testing

調査の方向性

backend/app/utils/hardware_detect.pyを読み、backend/testsにある既存のテストパターンに従ってください。モックしたシステムコールを使って、名前が挙げられた5つの公開関数と、列挙されたエッジケースを網羅するbackend/tests/test_hardware_detect.pyを追加してください。新しいテストファイルを実行してください。物理ハードウェアを必要とせず、指定された検出経路でテストが通れば完了です。

索引モデルが issue の本文から書いたものです。

説明

enhancement

What's missing

backend/app/utils/hardware_detect.py has zero test coverage right now. This module is responsible for figuring out what hardware a user's machine has (GPU, Apple Silicon, RAM) and recommending the right AI model tier (nano / small / medium). It's a pretty critical piece — if something breaks here, users silently end up with the wrong model for their hardware.

What I'd like to add

A test file backend/tests/test_hardware_detect.py covering all 5 public functions:

  • detect_physical_gpu() — nvidia-smi not found, single/multiple GPU parsing, error handling (OSError, timeout), blank-line stripping
  • detect_apple_silicon() — non-Mac returns None, non-arm64 returns None, sysctl happy path, sysctl failure fallback chain (processor → generic string)
  • detect_apple_silicon_tier() — base M1/M2 → small, Pro/Max/Ultra/M3+ → medium, non-Apple → None
  • detect_hardware_tier() — Apple Silicon path, GPU-present path, RAM-based tiers, boundary values at exactly 4 GB and 8 GB
  • get_hardware_info() — returned dict has the right keys and values, gpu_detected flag correctness

All system calls (shutil.which, subprocess.run, platform.*, psutil.virtual_memory, ort.get_available_providers) will be mocked so the tests run on any machine without needing actual hardware.

Why it matters

This module quietly drives model selection for the whole app. Having tests here means we catch regressions early — especially around edge cases like timeouts, missing tools, or future chip names.


I'd like to work on this — I've already explored the module and have a good idea of what the test cases should look like. Happy to put up a PR!

主要言語
Python
スター
322
フォーク
793
平均マージ
6日 11時間
マージ済み PR(30日)
21

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

AOSSIE-Org/PictoPy のほかの issue

AOSSIE-Org/PictoPy の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。