Skip to content

Fix/resume-when-finished#9

Merged
dmandache merged 2 commits intomainfrom
fix/resume-when-finished
Mar 4, 2026
Merged

Fix/resume-when-finished#9
dmandache merged 2 commits intomainfrom
fix/resume-when-finished

Conversation

@dmandache
Copy link
Owner

This PR improves checkpoint resume behavior across long-running commands and fixes a segment-specific resume inefficiency.

When --resume is enabled and checkpoint state already indicates the run is finished, commands now short-circuit instead of re-entering execution.

Additionally, in segment, postprocessing is now skipped for rows that were already completed (i.e., outputs already exist and no task was re-run), preventing unnecessary overwrite work.

What changed

  1. Unified “already finished” resume handling
    Added already_finished in resume context (run_state.prepare_resume_context).
    parse, convert, segment, phase, and radiomics now return early when:
    resume state matches current args/input fingerprint, and
    checkpoint state has finished=true.
  2. Avoid eager heavy initialization when run is already finished
    Moved expensive setup to occur after the early-finish check where relevant:
    segment: config/model prefetch deferred until after resume-finished guard.
    phase: phase extractor loading deferred.
    radiomics: dependency loading and extractor creation deferred.
  3. Segment postprocessing skip for checkpointed rows
    In segment_volume, added task-run tracking (ran_any_task).
    If merged output already exists, force=False, and no task executed for that row, postprocessing is skipped.
    This avoids re-running merge/cleanup for rows that were already processed before interruption.

Why this matters

  • Reduces wasted work on resumed pipelines.
  • Prevents unnecessary postprocessing rewrites in segment runs.
  • Improves restart reliability and runtime efficiency for checkpoint-heavy workflows.

@dmandache dmandache merged commit 770c58a into main Mar 4, 2026
3 checks passed
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 132323148d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

args_hash=args_hash,
input_fingerprint=input_fp,
)
already_finished = can_resume and bool((state or {}).get("finished"))

Choose a reason for hiding this comment

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

P2 Badge Gate finished short-circuit on output availability

prepare_resume_context now marks runs as already_finished based only on the state file’s finished flag, but several command entrypoints (convert.main, segment.main, phase.main, radiomics.main) immediately return on that flag without verifying that the final output CSV still exists. If a previous run finalized state and the output file is later deleted or lost, --resume will no-op and leave the command with no produced output, which breaks recovery workflows that rely on checkpoint artifacts.

Useful? React with 👍 / 👎.

@codecov
Copy link

codecov bot commented Mar 4, 2026

Codecov Report

❌ Patch coverage is 88.88889% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/imperandi/ingest/parse.py 62.50% 3 Missing ⚠️
src/imperandi/process/segment.py 91.66% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

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.

1 participant