Skip to content

Add 'Classify Video' context-menu action to classify a single video#411

Merged
gbeane merged 3 commits into
mainfrom
feature/klaus-504-classify-single-video
Jul 14, 2026
Merged

Add 'Classify Video' context-menu action to classify a single video#411
gbeane merged 3 commits into
mainfrom
feature/klaus-504-classify-single-video

Conversation

@gbeane

@gbeane gbeane commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds a "Classify Video" action to the right-click context menu in the project video list, so a user can classify a single video on demand instead of running classification across every video in the project.

Primary use case: right-click a video → "Exclude from Training", train a new classifier, then right-click that same video → "Classify Video" to inspect how the classifier performs on that specific held-out video.

Jira: KLAUS-504

Behavior

  • The menu action is enabled only when a trained classifier is ready for the current behavior (mirrors the main Classify button's enabled state).
  • Classifies the selected video for the currently selected behavior.
  • Predictions are saved to disk via the normal prediction-save path.
  • After classification completes, JABS auto-switches to the classified video so its freshly computed predictions are displayed.
  • Excluded-from-training videos remain classifiable (exclusion only affects training).

Changes

  • ui/classification_thread.pyClassifyThread gained an optional videos: list[str] | None param; run() iterates that subset when given, else all project videos (default None = existing behavior).
  • ui/main_window/central_widget.py_classify_button_clicked delegates to a shared _start_classification(videos); new classify_single_video(name) entry point; re-entry guard while a run is active; completion handler refreshes the view only when the loaded video was classified, otherwise emits request_video_selection to auto-switch; classify-button enabled state centralized into _set_classify_enabled() which emits a new classify_availability_changed signal.
  • ui/main_window/video_list_widget.py — new "Classify Video" context-menu action, classify_video_requested signal, and set_classify_available().
  • ui/main_window/main_window.py — wires the new signals between the video list dock and the central widget.

Testing

  • 7 new unit tests: subset/empty classification in ClassifyThread, menu action enablement + signal emission, _set_classify_enabled, single-video start guard, and all three completion branches (refresh-all, refresh-loaded-in-subset, auto-switch).
  • uv run pytest tests/ui → 121 passed.
  • ruff check . and ruff format --check → clean.
  • manual end to end testing

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a “Classify Video” context-menu action to the project video list, enabling on-demand classification of a single selected video using the currently selected behavior, while reusing the existing classification pipeline and save-to-disk behavior.

Changes:

  • Extend ClassifyThread to optionally classify only a provided subset of video filenames (default remains “classify all”).
  • Add central-widget helpers/signals to start subset classification, guard against re-entry, and auto-switch to the classified video when appropriate.
  • Add a new video-list context-menu action and wire it through MainWindow, with unit tests covering new branches and signal behavior.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/ui/test_video_list_widget.py Adds tests for context-menu action enablement and signal emission for “Classify Video”.
tests/ui/test_classification_thread.py Adds tests validating subset and empty-subset behavior in ClassifyThread.
tests/ui/test_central_widget.py Adds tests for classify availability signaling, single-video start behavior, re-entry guard, and completion-branch behavior.
src/jabs/ui/main_window/video_list_widget.py Implements the “Classify Video” context-menu action, a new signal, and availability toggling.
src/jabs/ui/main_window/main_window.py Wires new signals between the video list dock and central widget (request/availability/auto-switch).
src/jabs/ui/main_window/central_widget.py Centralizes classify-enabled state, adds subset classification entry point, tracks classification targets, and updates completion handling.
src/jabs/ui/classification_thread.py Adds optional videos parameter to restrict iteration to a provided list.
src/jabs/scripts/cli/cli.py Removes an overly-specific type annotation for CLASSIFIER_CHOICES (no behavior change).
Comments suppressed due to low confidence (1)

src/jabs/ui/main_window/central_widget.py:1131

  • _classification_targets is cleared on successful completion, but not on the error/cancel path. If classification fails or is canceled, this leaves stale state hanging around, which can make future branching logic around targets harder to reason about (and risks accidental reuse if the attribute is consulted elsewhere later). Consider clearing it in _classify_thread_error_callback as part of cleanup.
            self._set_classify_enabled(False)

    def _classify_thread_error_callback(self, error: Exception) -> None:
        """handle an error in the classification thread"""
        self._cleanup_classify_thread()

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@gbeane gbeane requested review from bergsalex and keithshep July 13, 2026 20:55
@gbeane gbeane self-assigned this Jul 13, 2026
@gbeane gbeane merged commit b47b49c into main Jul 14, 2026
5 checks passed
@gbeane gbeane deleted the feature/klaus-504-classify-single-video branch July 14, 2026 20:43
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.

3 participants