Skip to content

fix(jobs): show collect stage progress#1286

Open
mihow wants to merge 2 commits intomainfrom
fix/job-progress-collect-stage-save
Open

fix(jobs): show collect stage progress#1286
mihow wants to merge 2 commits intomainfrom
fix/job-progress-collect-stage-save

Conversation

@mihow
Copy link
Copy Markdown
Collaborator

@mihow mihow commented May 1, 2026

Summary

When jobs start, they often transition to STARTED, but show now progress and the stages stay gray / unstarted. This is usually because the "collect" stage is running, but the status was not updated when the collect stage started.

Two small, independent fixes bundled in one PR:

  • fix(jobs)_run_pipeline_job updates the collect stage to STARTED in memory but doesn't save() until after collect_images() returns. For large collections that call can run for minutes, so polling clients (UI) see a frozen job. Add job.save() right after marking the stage STARTED.
  • chore(jobs) — commit the deferred 0023_alter_job_job_type_key migration. This is the cosmetic choices-label drift from 585cd55a (collection → capture set rename) that was explicitly excluded from Refactor job logging to use separate table #1259 to keep that diff focused. No schema change; just keeps makemigrations --check green.

Before:
image

After:
image

Test plan

  • python manage.py makemigrations --check passes
  • Trigger an ML job against a large collection; confirm the UI shows the collect stage as in-progress while collect_images() is still running (instead of appearing frozen until collection finishes)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Job state now persists immediately upon initialization of the collection stage, ensuring status updates are reflected without delay.
  • Chores

    • Updated job type field constraints to enforce valid job type identifiers.

mihow and others added 2 commits April 30, 2026 17:23
Cosmetic choices-label change from 585cd55 (collection→capture set rename)
that was excluded from #1259 to keep that diff focused. No DB schema change;
keeps makemigrations --check green.

Co-Authored-By: Claude <noreply@anthropic.com>
update_stage() mutates job.progress in memory but never hits the DB until
the post-collect job.save() at line 533. collect_images() can take minutes
for large collections, so the UI sees no stage activity and looks frozen.
Save right after marking the stage STARTED so polling clients see it.

Co-Authored-By: Claude <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 1, 2026 00:23
@netlify
Copy link
Copy Markdown

netlify Bot commented May 1, 2026

Deploy Preview for antenna-preview canceled.

Name Link
🔨 Latest commit f1eb099
🔍 Latest deploy log https://app.netlify.com/projects/antenna-preview/deploys/69f3f292fe7e4900087e1908

@netlify
Copy link
Copy Markdown

netlify Bot commented May 1, 2026

Deploy Preview for antenna-ssec canceled.

Name Link
🔨 Latest commit f1eb099
🔍 Latest deploy log https://app.netlify.com/projects/antenna-ssec/deploys/69f3f29214b99e0008865179

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 1, 2026

📝 Walkthrough

Walkthrough

This PR adds a Django migration to define allowed choices and constraints for the Job.job_type_key field, and modifies the ML job image collection flow to persist the job immediately after initializing the "collect" stage, ensuring earlier visibility of state changes.

Changes

Cohort / File(s) Summary
Job Type Field Migration
ami/jobs/migrations/0023_alter_job_job_type_key.py
Defines choices (ml, populate_captures_collection, data_storage_sync, unknown, data_export, post_processing), constraints (max_length=255), default value ("unknown"), and verbose name ("Job Type") for the Job.job_type_key field.
Job Persistence Logic
ami/jobs/models.py
Persists job to database immediately after initializing the "collect" stage to STARTED with progress=0, ensuring state changes are visible earlier in the ML job image collection flow.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐰 This rabbit hops with code so true,
Job types constrained to just a few,
Now save each stage without delay,
State changes visible right away! 🎯

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title 'fix(jobs): show collect stage progress' directly describes the main fix in the changeset, which persists job state immediately after marking collect stage as STARTED to show progress in the UI.
Description check ✅ Passed The pull request description follows the template structure with Summary, List of Changes, Related Issues, Detailed Description, How to Test, Screenshots, and Deployment Notes sections. All required sections are present and substantively completed.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/job-progress-collect-stage-save

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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 PR improves job progress visibility during long-running ML “collect” operations and adds a deferred migration to keep job_type_key choices in sync after the “collection” → “capture set” rename.

Changes:

  • Persist collect stage STARTED progress immediately so polling clients see active progress during collect_images().
  • Add migration 0023_alter_job_job_type_key to update the job_type_key choice label (“Populate captures collection” → “Populate capture set”) and keep makemigrations --check clean.

Reviewed changes

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

File Description
ami/jobs/models.py Saves the job immediately after marking the collect stage as STARTED, preventing UI polling from appearing frozen during long collection runs.
ami/jobs/migrations/0023_alter_job_job_type_key.py Alters job_type_key field choices to reflect updated human-readable label for the populate job type.

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

@mihow mihow changed the title fix(jobs): show collect stage progress + add deferred job_type_key migration fix(jobs): show collect stage progress May 1, 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