refactor: Implement parallel processing for image rotation#50
refactor: Implement parallel processing for image rotation#50duartebarbosadev merged 2 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This pull request introduces parallel processing for image rotation operations to improve performance and UI responsiveness during bulk rotations. The implementation uses ThreadPoolExecutor to process multiple images concurrently while maintaining thread-safe progress tracking and proper error handling.
Key Changes
- Added
RotationApplicationWorkerwith parallel processing capabilities usingThreadPoolExecutor - Refactored UI rotation workflow to delegate to the new worker for both single and batch operations
- Updated UI to perform batch preview regeneration and thumbnail updates after rotations complete
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_rotation_application_worker.py | Added comprehensive test coverage for parallel processing modes, thread safety, and cancellation |
| src/workers/rotation_application_worker.py | Implemented parallel processing with ThreadPoolExecutor and thread-safe progress tracking |
| src/ui/main_window.py | Refactored rotation logic to use worker and added batch thumbnail update method |
| src/ui/app_controller.py | Added deferred UI updates and batch processing for post-rotation operations |
| DEVELOPER_GUIDE.md | Updated documentation to describe parallel processing approach |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| self, mock_metadata_processor, mock_calculate_max_workers | ||
| ): | ||
| """Test that progress tracking is thread-safe in parallel mode""" | ||
| from PyQt6.QtCore import Qt |
There was a problem hiding this comment.
[nitpick] This import is only used once on line 415. Consider importing Qt.ConnectionType.DirectConnection directly or moving the import closer to its usage to avoid importing the entire Qt module.
| import threading | ||
| import concurrent.futures |
There was a problem hiding this comment.
[nitpick] Consider grouping standard library imports alphabetically or by category. The concurrent.futures import could be placed after the threading import for better organization.
This pull request introduces parallel batch rotation support for images, improving performance and UI responsiveness during bulk operations. The changes refactor rotation workflows to use a new
RotationApplicationWorkerwithThreadPoolExecutorfor parallel execution, and update the UI to efficiently handle batch preview and thumbnail updates after rotations. Documentation has also been updated to describe parallel processing practices.Parallel batch rotation support and workflow refactoring
RotationApplicationWorkerto support parallel processing of batch image rotations usingThreadPoolExecutor, with the number of workers determined bycalculate_max_workers()fromapp_settings.py[1] [2]._rotate_selected_imagesinmain_window.pyto delegate batch rotation operations to the new worker viaapp_controller._apply_approved_rotations, removing sequential rotation logic and lossy confirmation dialogs from the UI layer [1] [2].Efficient UI updates after batch rotations
app_controller.pyto defer UI-heavy updates (preview regeneration, selection refresh) until batch completion, performing only lightweight cache invalidation during individual rotations. Batch preview regeneration and thumbnail updates are now performed in parallel after all rotations finish._batch_update_rotated_thumbnailstomain_window.pyfor efficient batch thumbnail updates after rotations.Documentation updates
DEVELOPER_GUIDE.mdto document the new parallel processing approach, including usage ofThreadPoolExecutorfor workers and the design ofRotationApplicationWorker[1] [2].Internal state management
_pending_rotated_pathsinapp_controller.pyto track images awaiting post-rotation UI updates.Worker implementation improvements
RotationApplicationWorkerto provide a thread-safe progress counter and a single-image rotation helper for use in both sequential and parallel paths [1] [2] [3].