mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Makes the CI prioritize running any test files that had a failing test in a previous iteration of the given PR. A follow up to https://github.com/pytorch/pytorch/pull/100522 which makes the `.pytest_cache` available to use here A concrete example: 1. Person A pushes a new commit and creates a PR. 2. 2 hours later, test_im_now_broken.py fails 3. Person A attempts to fix the test, but the test is actually still broken 4. The CI, seeing that test_im_now_broken.py had failed on a previous run, will now prioritize running that test first. Instead of waiting another 2 hours to get a signal, Person A only needs to wait ~15 minutes (which is how long it takes for tests to start running) # Testing I modified a file to make the tests invoking it fail and triggered CI twice with this failure. First run: https://github.com/pytorch/pytorch/actions/runs/4963943209/jobs/8883800811 Test step took 1h 9m to run Second run: https://github.com/pytorch/pytorch/actions/runs/4965016776/jobs/8885657992 Test step failed within 2m 27s Pull Request resolved: https://github.com/pytorch/pytorch/pull/101123 Approved by: https://github.com/malfet, https://github.com/huydhn
20 lines
503 B
Python
20 lines
503 B
Python
def pluralize(count: int, singular_word: str, plural_word: str = "") -> str:
|
|
if count == 1:
|
|
return f"{count} {singular_word}"
|
|
|
|
if not plural_word:
|
|
plural_word = f"{singular_word}s"
|
|
|
|
return f"{count} {plural_word}"
|
|
|
|
|
|
def duration_to_str(seconds: float) -> str:
|
|
if seconds < 0.00001:
|
|
return "0s"
|
|
elif seconds < 60:
|
|
return f"{seconds:.1f}s"
|
|
elif seconds < 3600:
|
|
return f"{seconds / 60:.1f}m"
|
|
else:
|
|
return f"{seconds / 3600:.1f}h"
|