refactor: 2ライン方式の採用に伴うディレクトリ整理 - #104
Draft
ucn-yushin wants to merge 13 commits into
Draft
Conversation
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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
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.
対応Issue
ディレクトリ整理そのもののIssueは立てていません。方式決定の経緯は以下を参照してください。
なぜやったか
PR #90 で2ライン方式の採用が決まり、リポジトリの位置づけが「複数方式を並べて比較する実験リポジトリ」から「採用方式を運用するプロダクト」へ変わった。しかし構造は実験時代のままで、以下の問題があった。
sys.path.insertでcommonを import しているpyproject.tomlと各所のrequirements.txtに二重化している.gitignoreがdocs/を丸ごと無視しており、方式決定の記録をコミットできないcommon/tests、line_detection/tests、eval/testsの3箇所に分散している何をやったか
レガシーの削除
raspi/detect/(SAHI+YOLOの旧台数計測)、raspi/sensor/(センサー方式のハンズオンサンプル)、cron/(sakura.ioからのデータ取得)、run_gate4_alternating.py(ROI方式との速度比較、完了済み)を削除した。削除前の状態はarchive/pre-cleanupタグに保存してある。srcレイアウトへの移行
pyproject.tomlに hatchling のビルド設定を追加し、uv syncで editable install されるようにした。これにより全ファイルのsys.path.insertを削除し、from tracking_parking.common.x import ...の絶対 import に統一した。raspi/line_detection/requirements.txtは依存定義がルートと重複していたため削除した。意思決定の記録
.gitignoreのdocs/一括除外をやめ、docs/decisions/0001-two-line-method.mdとして2ライン方式採用のADRを追加した。速度・集計精度の比較結果、決め手になった「実行と観測の基盤」の差に加えて、この決定が主張していないこと(イベント単位の精度は未評価、エッジ実機でのロバスト性は未検証など)と、ROI方式の削除で失われるパラメータ探索基盤を引き継ぐ課題として明記している。ルート
README.mdも書き直した(従来はwikiへのリンク1行のみ)。どのように実装したか
レビューしやすさのため、フェーズごとにコミットを分けている。
chore:レガシー削除(対象ごとに1コミット、ロールバック可能な粒度)refactor: srcレイアウトへディレクトリを移動(内容変更なし)—git mvのみ。89ファイルがリネームとして検出されており履歴が追えるrefactor: パッケージ化しimportからsys.pathハックを除去— import書き換えとパッケージ化chore:/docs:—.gitignore整理、ADR追加、ドキュメントの旧パス更新scripts/はパッケージではないため、テストからの import パス解決はtests/conftest.pyの1箇所に集約した(各テストでのsys.path操作は全廃)。.env/ モデル重み / データの既定パスはすべてリポジトリルート基準へ統一した(data/inputs、data/outputs、models/)。画面スクリーンショット等
URLスクリーンショット
テスト項目
uv sync後、uv run pytest -qが全件パスすること(手元では198件パス、移行前と同数)uv run python -c "import tracking_parking"が成功することscripts/配下4本の--helpがエラーなく表示されることscripts/run_detection.pyを実行し、data/outputs/へイベントログとmanifestが出力されることsetup_lines.pyで保存したとき.envのライン座標以外の設定が保持されること備考
raspi/roi-counter/の未追跡データを削除した際、そこに置かれていた正解台数ファイル*_gt.json6本を一緒に消してしまいました(dataが.gitignore対象のため、Git・バックアップのいずれからも復元できませんでした)。過去runのmanifestに
gt_in/gt_outが記録されていたため、そこからdata/inputs/configs/へ再構成しています。値は6動画すべて復元できていますが、ファイルのSHA-256は元と一致しません。condition_keyにGTのハッシュが含まれるため、今後のrunは過去runと同一条件とはみなされなくなります。1787008160.558032(55/0),1787009706.719727(30/2),1787011229.231516(2/3),1787012751.179971(7/1),1787014266.421887(3/3),IMG_2787(22/0)roiフィールドは復元していません(ROI方式は削除済みのため不要)events(イベント時刻)が入っていた形跡は、どの出力にも見当たりませんでした手元に元ファイルの控えがある場合は差し替えてください。
その他
feat/mike/89-bbox-analysis-within-roiブランチに健在です。archive/pre-cleanupタグ(developba00a9e時点)を一緒にpushしています。docs.local/は従来どおりGit管理外のままです。