Skip to content

Fix detection completion % calculation in bulk import task#1532

Open
JasonWildMe wants to merge 13 commits into
mainfrom
fix-detection-percent-calculation
Open

Fix detection completion % calculation in bulk import task#1532
JasonWildMe wants to merge 13 commits into
mainfrom
fix-detection-percent-calculation

Conversation

@JasonWildMe
Copy link
Copy Markdown
Collaborator

Summary

Fixes the bulk import task page (/react/bulk-import-task) showing detection completion < 100% even when all MediaAssets have completed detection and have annotations.

Root cause

Three bugs in ImportTask.iaSummaryJson():

  1. Numerator/denominator population mismatch: The numerator (numDetectionComplete) counted any asset with detectionStatus complete/pending — including non-IA-eligible assets (videos, corrupt images). These incremented the numerator but not the denominator (numAllowedIA), so numDetectionComplete == numAllowedIA could never pass, or the in-progress percentage could exceed 100%.

  2. Only checked detectionStatus, not actual annotations: Assets that acquired annotations through non-IA paths (manual annotation via the API, data import, migration) were never counted as detection-complete because the code only inspected detectionStatus, not whether non-trivial annotations actually existed on the asset.

  3. Inconsistent denominators between completion check and progress fraction: The completion equality check used numAllowedIA (IA-eligible assets) but the progress percentage divided by numAssets (total assets). This meant in-progress percentages were diluted by ineligible assets that could never complete detection.

Changes

MediaAsset.java — Added hasNonTrivialAnnotations(): returns true if the asset has any annotation where isTrivial() is false (i.e., not just the whole-image placeholder bounding box created during import).

ImportTask.java — Reworked the iaSummaryJson() per-asset loop:

  • Single isEligible flag per asset gates both numAllowedIA and numDetectionComplete counters — ensures numerator and denominator draw from the same population
  • An eligible asset counts as detection-complete if: detectionStatus is "complete" or "pending", OR the asset has non-trivial annotations
  • Both legacy and non-legacy paths now use numAllowedIA as the denominator for the completion equality check, progress fraction, and divide-by-zero guard

Test plan

  • Bulk import task with all images detected successfully → shows 100%
  • Bulk import task with mix of images and non-image files (e.g. video) → non-image files don't drag down the percentage
  • Bulk import task where some assets were manually annotated (not via IA pipeline) → manually annotated assets count as complete
  • Bulk import task with only non-IA-eligible assets → no divide-by-zero, percentage not shown
  • Legacy import tasks (no iaTask) → same corrected behavior

🤖 Generated with Claude Code

JasonWildMe and others added 13 commits April 10, 2026 11:47
…nator

The bulk import task page (/react/bulk-import-task) could show detection
< 100% even when all MediaAssets had completed detection and annotations.

Three bugs in ImportTask.iaSummaryJson():

1. Numerator counted ANY asset with detectionStatus complete/pending,
   including non-IA-eligible assets (videos, corrupt images). These
   incremented numDetectionComplete but not numAllowedIA, so the
   completion check (numDetectionComplete == numAllowedIA) could never
   pass, or the percentage could exceed 100%.

2. Assets that acquired annotations through non-IA paths (manual
   annotation, data import, migration) were not counted as detection-
   complete because the check only looked at detectionStatus, not
   whether annotations actually existed.

3. The progress denominator used numAssets (total) while the completion
   check used numAllowedIA (IA-eligible), so even when the equality
   check passed, in-progress percentages were diluted by ineligible
   assets.

Fix: use a single isEligible flag per asset that gates both the
numAllowedIA and numDetectionComplete counters. An eligible asset
counts as detection-complete if it has detectionStatus complete/pending
OR has non-trivial annotations (i.e. not just the whole-image placeholder
bounding box). Both legacy and non-legacy paths now use numAllowedIA as
denominator for the completion check, progress fraction, and divide guard.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The re-identification button on the bulk import task page was gated on
task.status === "complete", but ImportTask.status is never transitioned
from "processing-detection" to "complete" after IA detection finishes.
The only code paths that set it to "complete" are when detection is
skipped or via the legacy StandardImport pathway.

Since task.iaSummary.detectionStatus already accurately reflects whether
detection has completed (and is checked on the same line), the
ImportTask.status check is both redundant and broken. Remove it so the
button is enabled once detection is genuinely complete.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@JasonWildMe JasonWildMe requested a review from naknomum April 20, 2026 21:42
@JasonWildMe JasonWildMe self-assigned this Apr 20, 2026
@naknomum naknomum added this to the 10.10.5 milestone May 5, 2026
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