summarylogtreecommitdiffstats
path: root/pytest-rank-runner.py
blob: 8b20ae1a50a1cd4247cdf21fc383f6b59a6271b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/python
"""Run pytest with a private temp directory for each re-executed DDP rank."""

import os
import sys
from pathlib import Path

import pytest


def main() -> int:
    base = Path(os.environ["PL_PYTEST_BASETEMP"])
    base.mkdir(parents=True, exist_ok=True)
    rank = os.environ.get("LOCAL_RANK", "0")
    basetemp = base / f"rank-{rank}"
    return pytest.main([f"--basetemp={basetemp}", *sys.argv[1:]])


if __name__ == "__main__":
    raise SystemExit(main())