Repository navigation
refactor(api): Extract JobStore and image request utilities - #53
Conversation
Extract InMemoryJobStore to src/api/job_store.py and image extraction logic with security limits to src/api/image_utils.py for improved modularity and separation of concerns while preserving backward compatibility. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
概要
コード品質向上と責務分離を目的として、
src/api/main.py内に混在していたInMemoryJobStoreおよび_get_image_from_requestヘルパー・各種セキュリティ定数をそれぞれ以下の新モジュールに抽出・分割しました。src/api/job_store.py:InMemoryJobStore(LRU / TTL 退避およびスレッドセーフなインメモリジョブ管理)src/api/image_utils.py:_get_image_from_request(multipart/JSON Base64 入力検証・画像抽出・制限チェック)後方互換性維持のため、
src/api/main.pyにてインポートおよび再エクスポートを行い、既存のAPIシグネチャやmonkeypatchを用いたテスト環境との互換性を完全に確保しています。各ステップでの変更内容およびテスト実行結果
PYTHONPATH=. uv run pytestを実行し、既存の69件のテストがすべて成功(Green)することを確認。test_job_store_limits.py,test_limits.py,test_boundary_conditions.py) により対象の挙動がカバーされていることを確認。InMemoryJobStoreをsrc/api/job_store.pyに分割し、動作検証(Pytest 69件全パス)。_get_image_from_requestおよびセキュリティ定数をsrc/api/image_utils.pyに分割し、main.pyから再エクスポート。動的属性参照 (getattr) に対応させてmonkeypatchテストとの互換性を確保・検証(Pytest 69件全パス)。uv run ruff check) および全ユニットテストを実行し、すべて正常に完了。PR created automatically by Jules for task 1701715953450701877 started by @chottokun