Skip to content

Commit

Permalink
Add distributed barrier test fixture to ensure pytest cleans up resou…
Browse files Browse the repository at this point in the history
…rces properly (#2694)
  • Loading branch information
j316chuck authored Nov 8, 2023
1 parent 29edfff commit 3830a55
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/fixtures/autouse_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@ def disable_wandb(monkeypatch: pytest.MonkeyPatch, request: pytest.FixtureReques
monkeypatch.setenv('WANDB_PROJECT', 'pytest')


@pytest.fixture(scope='session')
def cleanup_dist():
"""Ensure all dist tests clean up resources properly."""
yield
# Avoid race condition where a test is still writing to a file on one rank
# while the file system is being torn down on another rank.
dist.barrier()


@pytest.fixture(autouse=True, scope='session')
def configure_dist(request: pytest.FixtureRequest):
# Configure dist globally when the world size is greater than 1,
Expand Down

0 comments on commit 3830a55

Please sign in to comment.