Skip to content

refactor: Implement parallel processing for image rotation#50

Merged
duartebarbosadev merged 2 commits intomainfrom
refactor--async-rotation
Oct 8, 2025
Merged

refactor: Implement parallel processing for image rotation#50
duartebarbosadev merged 2 commits intomainfrom
refactor--async-rotation

Conversation

@duartebarbosadev
Copy link
Copy Markdown
Owner

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 RotationApplicationWorker with ThreadPoolExecutor for 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

  • Added RotationApplicationWorker to support parallel processing of batch image rotations using ThreadPoolExecutor, with the number of workers determined by calculate_max_workers() from app_settings.py [1] [2].
  • Refactored _rotate_selected_images in main_window.py to delegate batch rotation operations to the new worker via app_controller._apply_approved_rotations, removing sequential rotation logic and lossy confirmation dialogs from the UI layer [1] [2].

Efficient UI updates after batch rotations

  • Updated app_controller.py to 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.
  • Added _batch_update_rotated_thumbnails to main_window.py for efficient batch thumbnail updates after rotations.

Documentation updates

  • Updated DEVELOPER_GUIDE.md to document the new parallel processing approach, including usage of ThreadPoolExecutor for workers and the design of RotationApplicationWorker [1] [2].

Internal state management

  • Introduced _pending_rotated_paths in app_controller.py to track images awaiting post-rotation UI updates.

Worker implementation improvements

  • Refactored RotationApplicationWorker to provide a thread-safe progress counter and a single-image rotation helper for use in both sequential and parallel paths [1] [2] [3].

Copilot AI review requested due to automatic review settings October 8, 2025 12:40
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 RotationApplicationWorker with parallel processing capabilities using ThreadPoolExecutor
  • 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
Copy link

Copilot AI Oct 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

Copilot uses AI. Check for mistakes.
Comment on lines +10 to +11
import threading
import concurrent.futures
Copy link

Copilot AI Oct 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider grouping standard library imports alphabetically or by category. The concurrent.futures import could be placed after the threading import for better organization.

Copilot uses AI. Check for mistakes.
@duartebarbosadev duartebarbosadev merged commit 22f7e2b into main Oct 8, 2025
3 checks passed
@duartebarbosadev duartebarbosadev deleted the refactor--async-rotation branch October 8, 2025 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants