Repository navigation
fix: persistence starttime unset/defaults - #4251
Conversation
📝 WalkthroughWalkthroughPersistence metadata now records job start times when incomplete markers are created and reuses them when jobs finish. File and database backends implement starttime retrieval, with parametrized tests covering both implementations. ChangesStarttime recording
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant PersistenceBase
participant FilePersistence
participant DbPersistence
participant MetadataRecord
PersistenceBase->>FilePersistence: _get_recorded_starttime(key)
FilePersistence->>MetadataRecord: read incomplete marker or metadata record
PersistenceBase->>DbPersistence: _get_recorded_starttime(key)
DbPersistence->>MetadataRecord: read recorded starttime
PersistenceBase->>MetadataRecord: write completed metadata with preserved starttime
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/snakemake/persistence/__init__.py`:
- Line 506: Update the start-time assignment around _get_recorded_starttime to
use fallback_time only when the recorded value is None, preserving valid
timestamps such as 0.0.
In `@tests/test_persistence.py`:
- Around line 184-196: Strengthen test_normal_completion by capturing the
timestamp returned by persistence._get_recorded_starttime() immediately after
started(...), then assert rec.starttime equals that captured value exactly.
Retain the existing completion and record-state assertions while replacing the
broad before/after timestamp validation that permits a fallback timestamp.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: fbde688a-f9c6-4ce1-af4e-ddaccb018488
📒 Files selected for processing (4)
src/snakemake/persistence/__init__.pysrc/snakemake/persistence/db.pysrc/snakemake/persistence/file.pytests/test_persistence.py
|
|
||
| if record.starttime is None: | ||
| record.starttime = fallback_time | ||
| record.starttime = self._get_recorded_starttime(key) or fallback_time |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
Preserve valid epoch timestamps.
Line 506 treats 0.0 as missing and overwrites it with fallback_time. Check explicitly for None.
Proposed fix
- record.starttime = self._get_recorded_starttime(key) or fallback_time
+ recorded_starttime = self._get_recorded_starttime(key)
+ record.starttime = (
+ recorded_starttime
+ if recorded_starttime is not None
+ else fallback_time
+ )📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| record.starttime = self._get_recorded_starttime(key) or fallback_time | |
| recorded_starttime = self._get_recorded_starttime(key) | |
| record.starttime = ( | |
| recorded_starttime | |
| if recorded_starttime is not None | |
| else fallback_time | |
| ) |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/snakemake/persistence/__init__.py` at line 506, Update the start-time
assignment around _get_recorded_starttime to use fallback_time only when the
recorded value is None, preserving valid timestamps such as 0.0.
|
Thanks a lot! |
🤖 I have created a release *beep* *boop* --- ## [9.24.0](v9.23.1...v9.24.0) (2026-07-30) ### Features * allow to combine cases with otherwise in branch function ([#4262](#4262)) ([000ff52](000ff52)) ### Bug Fixes * avoid config hash crash for non-serializable values ([#4241](#4241)) ([1a27746](1a27746)) * compilation error when final line contains an f-string ([#4234](#4234)) ([9c5e7fe](9c5e7fe)) * Group error log formatting ([#4256](#4256)) ([bb6dcde](bb6dcde)) * leak of benchmark monitor threads ([#4259](#4259)) ([d37852e](d37852e)) * no benchmark warning when a process exits before it can be sampled ([#4260](#4260)) ([6738359](6738359)) * persistence starttime unset/defaults ([#4251](#4251)) ([56395c0](56395c0)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
This PR addresses #517 (comment) a regression introduced in #4012 by a) recording the current time as the starttime in the DB backend, b) re-instating the double-finish check for the file backend.
QC
docs/) is updated to reflect the changes or this is not necessary (e.g. if the change does neither modify the language nor the behavior or functionalities of Snakemake).AI-assistance disclosure
I used AI assistance for:
Summary by CodeRabbit