fix: show pending jobs before first completion#64
fix: show pending jobs before first completion#64yfarjoun wants to merge 2 commits intofg-labs:mainfrom
Conversation
The pending panel showed "No pending jobs" until the first job completed
because total_jobs was derived from the progress line ("X of Y steps
done"), which Snakemake only emits on completion.
Now infers total_jobs from the Job stats table (already parsed into
expected_job_counts) when the progress line hasn't appeared yet. This
lets the pending panel show correct counts and per-rule breakdown
immediately, updating as jobs start running.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
📝 WalkthroughWalkthroughThe changes modify Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@snakesee/tui/monitor.py`:
- Around line 3099-3106: The current code unconditionally uses
self._estimator.expected_job_counts to infer progress.total_jobs and can apply
stale counts from a previous log; update the guard so you only use
expected_job_counts when they were populated for the same log/context as the
current progress. In practice modify the logic around
_init_current_rules_from_log and the inference block to (a) ensure
_init_current_rules_from_log is called and succeeds for the current progress/log
before using expected_job_counts, or (b) add a lightweight context check (e.g.
compare a current_log_id/timestamp field on self._estimator or progress) and
reject/clear expected_job_counts if they don’t match; only then compute
inferred_total and replace(progress, total_jobs=inferred_total). Ensure you
reference and update self._estimator.expected_job_counts,
_init_current_rules_from_log, and progress.total_jobs in the change.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: f5863a7e-f7e1-4772-9e33-c0148beb70e1
📒 Files selected for processing (2)
snakesee/tui/monitor.pytests/test_tui.py
| if not self._estimator.expected_job_counts: | ||
| self._init_current_rules_from_log() | ||
| if self._estimator.expected_job_counts: | ||
| from dataclasses import replace | ||
|
|
||
| inferred_total = sum(self._estimator.expected_job_counts.values()) | ||
| if inferred_total > 0: | ||
| progress = replace(progress, total_jobs=inferred_total) |
There was a problem hiding this comment.
Guard total_jobs inference against stale expected_job_counts.
At Line [3099], inference uses any existing non-empty self._estimator.expected_job_counts without log scoping. That can apply stale/latest-run counts at Line [3104] and overwrite progress.total_jobs for the wrong run (especially in historical view).
💡 Suggested fix
diff --git a/snakesee/tui/monitor.py b/snakesee/tui/monitor.py
@@
- if progress.total_jobs == 0 and self._estimator is not None:
+ if (
+ progress.total_jobs == 0
+ and self._estimator is not None
+ and self._current_log_index == 0 # infer only for latest/live run
+ ):
if not self._estimator.expected_job_counts:
self._init_current_rules_from_log()
if self._estimator.expected_job_counts:
from dataclasses import replace
@@
if inferred_total > 0:
progress = replace(progress, total_jobs=inferred_total)diff --git a/snakesee/tui/monitor.py b/snakesee/tui/monitor.py
@@
- job_counts = parse_job_stats_counts_from_log(log_path)
- if job_counts:
- self._estimator.expected_job_counts = job_counts
+ job_counts = parse_job_stats_counts_from_log(log_path)
+ # Always replace to avoid carrying stale counts across runs/log switches
+ self._estimator.expected_job_counts = job_counts or None🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@snakesee/tui/monitor.py` around lines 3099 - 3106, The current code
unconditionally uses self._estimator.expected_job_counts to infer
progress.total_jobs and can apply stale counts from a previous log; update the
guard so you only use expected_job_counts when they were populated for the same
log/context as the current progress. In practice modify the logic around
_init_current_rules_from_log and the inference block to (a) ensure
_init_current_rules_from_log is called and succeeds for the current progress/log
before using expected_job_counts, or (b) add a lightweight context check (e.g.
compare a current_log_id/timestamp field on self._estimator or progress) and
reject/clear expected_job_counts if they don’t match; only then compute
inferred_total and replace(progress, total_jobs=inferred_total). Ensure you
reference and update self._estimator.expected_job_counts,
_init_current_rules_from_log, and progress.total_jobs in the change.
Summary
total_jobsfrom the Job stats table (expected_job_counts) when the Snakemake progress line hasn't appeared yet (it only appears after the first completion)Closes #(none — discovered during usage)
Test plan
TestPendingJobsBeforeCompletiontotal_jobsinferred from expected counts when progress line absent🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Tests