Skip to content

fix: parse checkpoint and localcheckpoint rule lines#53

Merged
nh13 merged 1 commit intomainfrom
nh/fix-checkpoint-parsing
Mar 28, 2026
Merged

fix: parse checkpoint and localcheckpoint rule lines#53
nh13 merged 1 commit intomainfrom
nh/fix-checkpoint-parsing

Conversation

@nh13
Copy link
Copy Markdown
Collaborator

@nh13 nh13 commented Mar 28, 2026

Summary

  • Snakemake logs checkpoint rules as checkpoint X: / localcheckpoint X: instead of rule X: / localrule X:
  • RULE_START_PATTERN only matched rule/localrule, making checkpoint jobs invisible to all log-based parsers — timing was lost or misattributed to whatever rule preceded the checkpoint in the log
  • Update regex to (?:local)?(?:rule|checkpoint) (\w+): and add checkpoint prefixes to LogLineParser fast-path checks

Test plan

  • 8 new tests: running/completed/failed/all-jobs parsing + LogLineParser for checkpoint lines
  • Includes a regression test verifying checkpoint doesn't steal the next rule's timing
  • Full suite (986 tests) passes
  • ruff, mypy clean

Closes #43

Summary by CodeRabbit

  • New Features

    • Extended parser to recognize and handle Snakemake checkpoint rules (including local variants) alongside regular rules.
  • Tests

    • Introduced comprehensive test suites for checkpoint parsing, including job status tracking and rule-association validation.

Snakemake logs checkpoint rules as "checkpoint X:" or
"localcheckpoint X:" instead of "rule X:" or "localrule X:".
RULE_START_PATTERN only matched the rule/localrule forms, making
checkpoint jobs invisible to all log-based parsers. This caused
checkpoint timing to be either lost or misattributed to whichever
rule preceded the checkpoint in the log.

Update RULE_START_PATTERN to match all four forms and add checkpoint
prefixes to the LogLineParser fast-path checks.

Closes #43
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 28, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e8c1f42b-3e48-4518-8e5e-9667990f7b66

📥 Commits

Reviewing files that changed from the base of the PR and between 684359e and 7f20192.

📒 Files selected for processing (3)
  • snakesee/parser/line_parser.py
  • snakesee/parser/patterns.py
  • tests/test_parser.py

📝 Walkthrough

Walkthrough

The parser now recognizes checkpoint rules (checkpoint and localcheckpoint) alongside standard rules. Pattern matching and line-parsing logic were expanded to detect and process checkpoint declarations, with comprehensive test coverage added for checkpoint behavior validation.

Changes

Cohort / File(s) Summary
Pattern Matching
snakesee/parser/patterns.py
Updated RULE_START_PATTERN regex to match both rule/localrule and checkpoint/localcheckpoint declarations using alternation: (?:local)?(?:rule|checkpoint) (\w+):
Parser Logic
snakesee/parser/line_parser.py
Broadened rule-start detection in parse_line() to recognize four prefixes ("rule ", "localrule ", "checkpoint ", "localcheckpoint ") when first character is in ("r","l","c"). Same downstream behavior: flush pending error, extract name, reset context, emit RULE_START event.
Test Coverage
tests/test_parser.py
Added checkpoint-specific log fixtures and test suites validating parser behavior for checkpoint jobs in running/completed/failed lists with correct metadata (rule, job_id, wildcards), and confirming LogLineParser emits RULE_START for checkpoint lines without consuming subsequent rule context.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Checkpoints now dance in parser's sight,
No longer hidden from the code's keen eye,
Rules and checkpoints together align,
Statistics bloom as they should design,
A rabbit's hop toward parsing just right!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: updating the parser to recognize checkpoint and localcheckpoint rule lines, matching the primary objective of fixing the checkpoint parsing issue.
Description check ✅ Passed The PR description clearly explains the problem, the solution implemented, and provides comprehensive testing details including test counts and verification that the full suite passes.
Linked Issues check ✅ Passed The changes directly address issue #43 by enabling checkpoint rule recognition in logs, which resolves the root cause of incorrect historical statistics for checkpoint rules.
Out of Scope Changes check ✅ Passed All changes are focused on checkpoint parsing: pattern updates, parser logic, and comprehensive tests—all directly related to the linked issue objective.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ 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 nh/fix-checkpoint-parsing

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.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.47%. Comparing base (684359e) to head (7f20192).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #53      +/-   ##
==========================================
+ Coverage   88.25%   88.47%   +0.21%     
==========================================
  Files          48       48              
  Lines        4692     4684       -8     
==========================================
+ Hits         4141     4144       +3     
+ Misses        551      540      -11     
Files with missing lines Coverage Δ
snakesee/parser/line_parser.py 98.70% <100.00%> (+4.23%) ⬆️
snakesee/parser/patterns.py 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@nh13 nh13 merged commit b0e3a49 into main Mar 28, 2026
9 of 10 checks passed
@nh13 nh13 deleted the nh/fix-checkpoint-parsing branch March 28, 2026 05:32
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.

Wrong historical statistics for checkpoints?

1 participant