Skip to content

Commit 5eddfe6

Browse files
committed
force sequential execution on tests sharing the global default cache dir
1 parent f77234f commit 5eddfe6

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

.github/workflows/ci-testing.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262
pytest tests \
6363
--ignore=tests/processing \
6464
--ignore=tests/raw \
65-
-n 2 --cov=litdata --durations=0 --timeout=120 --capture=no --verbose
65+
-n 2 --dist=loadgroup --cov=litdata --durations=0 --timeout=120 --capture=no --verbose
6666
6767
- name: Run processing tests sequentially
6868
run: |

tests/conftest.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,18 @@ def _thread_police():
162162
raise AssertionError(f"Test left zombie thread: {thread}")
163163

164164

165+
def pytest_collection_modifyitems(items):
166+
"""Force tests sharing the global default cache dir onto the same xdist worker.
167+
168+
Why: ``clean_pq_index_cache`` shutil.rmtree's ``~/.lightning/chunks`` on setup/teardown.
169+
Under ``pytest -n>1`` two such tests on different workers race, deleting each other's
170+
chunks mid-iteration. Requires the runner to pass ``--dist=loadgroup``.
171+
"""
172+
for item in items:
173+
if "clean_pq_index_cache" in getattr(item, "fixturenames", ()):
174+
item.add_marker(pytest.mark.xdist_group("hf_default_cache"))
175+
176+
165177
# ==== fixtures for parquet ====
166178
@pytest.fixture
167179
def pq_data():

0 commit comments

Comments
 (0)