recycle_on_failure and retries alternative - #157
Conversation
1e4b669 to
5dc71e1
Compare
|
A review from the bot:
|
|
This is ready for review. @giordano From the robot's reveiw, I ignored the @michel2323 Do you mind trying it out to ensure that this keeps the functionality you originally intended with #148? |
This comment was marked as resolved.
This comment was marked as resolved.
A test that corrupts process-wide state — the motivating case is a GPU whose driver ends up in a state where every subsequent allocation in the process fails — poisons every later test scheduled onto the same worker, turning one bad test into a cascade of failed files. The Distributed- based harness this package was extracted from recycled a worker after any failed test; restore that behavior behind `recycle_on_failure = true`, alongside the existing max-rss and crash recycling. With `retries = N`, tests that did not pass are re-run up to N times after the main run completes: sequentially, on a single fresh worker, with all other workers stopped. Parallel test runs create resource contention (several workers sharing one GPU or a limited amount of RAM), so a failure can mean "lost the resource race" rather than "broken": re-running on an otherwise-idle system distinguishes the two. Tests that failed due to contention reliably pass on the idle retry, while deterministic failures fail again and are reported exactly once — only the final attempt of each test enters the results, and retried tests are visibly marked in the output. Both options default to off.
Add a "Failure Handling" section to the advanced usage guide covering both options: why worker recycling after a failure is useful (process-wide state corruption cascading onto later tests on the same worker) and what the retry environment guarantees (all other workers stopped, sequential re-run on a fresh worker, only the final attempt reported, retry worker recycled after a repeat failure). Also mention them in the feature list on the front page, and add a best practice warning against using retries to paper over genuinely broken tests.
For `recycle_on_failure`, run a fixed sequence of failing and passing tests with a single job and count the workers created: the default reuses one worker for all of them, while `recycle_on_failure=true` needs a fresh worker after each failure. For `retries`, use a test that fails on its first attempt and passes on any subsequent one (recording attempts in a file, since each attempt runs in a different process) to check that a test rescued by a retry is reported as passing, and that it is the only worker alive while it runs. A persistently failing test is checked to exhaust its retries and still be reported exactly once. Also cover that retries are off by default and skipped under `--quickfail`.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
giordano
left a comment
There was a problem hiding this comment.
I'm liking this new design, better integrated with the existing infrastructure. Thanks a lot for working on it! Should this PR be updated on top of main to include #162?
One thought I had was: should we think about an API to only allow certain tests to be retried? You may have few tests that you know are flaky, but don't want to waste time retrying more robust tests that are likely genuinely failing. However I'm concerned this API may become too convoluted, for perhaps little gain.
The stack already took care of that!
A lot of my ideas for this package stay ideas for this reason haha. Were you picturing test name filtering or something more fancy? Either way this can probably be implemented in a non-breaking way (ie future PR) |
Oh, I missed these two PRs were stacked, neat.
Yeah, something like that, but didn't think of how to pass the list of names.
Uhm, ok, you're probably right. |
giordano
left a comment
There was a problem hiding this comment.
@michel2323 it'd be nice to get your feedback, and if you can test it, but this looks good to me
While reviewing #148 I wasn't too happy with how the retries feature was reimplementing a simple version of the package so I started looking into reusing the same test machinery for the retries too.
Failing tests show up as yellow if they are to be retried.
Example output:
It's mostly working. Only 2 things left to do:
Close #148.