Skip to content

Tolerate coarse filesystem mtimes when confirming a short PSCAD run - #142

Open
qian-harvard wants to merge 1 commit into
mainfrom
fix/pscad-coarse-mtime-freshness
Open

qian-harvard wants to merge 1 commit into
mainfrom
fix/pscad-coarse-mtime-freshness

Conversation

@qian-harvard

Copy link
Copy Markdown
Contributor

Problem

run_project_to_completion treats a run that finished between status polls as completed only when an output file is fresh. A fresh file has changed since the pre-run snapshot and is stamped at or after the recorded run start (time.time_ns()).

File mtimes come from a coarser clock than time.time_ns(): kernel ticks on Linux, 2 s on FAT. Output written right after start can therefore be stamped a few milliseconds before it, and a completed run comes back as not_completed.

This made test_run_to_completion_accepts_short_run_between_polls fail intermittently on Linux CI. The first run of the #138 merge on main failed this way on Python 3.10, and the re-run passed.

Fix

Allow 2 s of slack on the mtime comparison in _project_output_changed. The snapshot diff already proves the file changed during this call, so the slack can't admit stale output. Files with old timestamps are still rejected.

Tests

  • test_run_to_completion_tolerates_coarse_filesystem_mtime stamps the output 1 s before it was written. It fails on main with the same 'not_completed' != 'completed' as CI and passes with the fix.
  • test_run_to_completion_rejects_output_far_older_than_run stamps the output an hour back. It checks that the slack stays bounded and that this output is still rejected.
  • PSCAD/tests: 28 passed. Full CI suite locally on Python 3.12: 826 passed, 0 failed.

🤖 Generated with Claude Code

run_project_to_completion accepts a run that finished between status polls
only when an output file is fresh: changed since the pre-run snapshot and
stamped at or after the recorded run start. File mtimes come from a coarser
clock than time.time_ns() (kernel ticks on Linux, 2 s on FAT), so output
written right after start could be stamped just before it, and a completed
run was reported as not_completed. This made
test_run_to_completion_accepts_short_run_between_polls fail intermittently
on Linux CI.

Allow 2 s of slack on the mtime comparison. The snapshot diff already proves
the file changed during this call, and files with old timestamps are still
rejected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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