Skip to content

Commit 145dc25

Browse files
authored
[pytest] Use knobs to setup fresh cache for testing (#6705)
With the new knobs module we have a more pythonic way to setup the cache. Other than being 'pythonic', switching to use knobs ensures the fresh cache will override any previously set cache path (e.g. if you have generic initialization logic which sets up these knobs, which we do have at Meta).
1 parent 8e23157 commit 145dc25

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

python/test/unit/conftest.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import os
21
import pytest
32
import tempfile
43
from typing import Optional, Set
@@ -20,11 +19,10 @@ def device(request):
2019
@pytest.fixture
2120
def fresh_triton_cache():
2221
with tempfile.TemporaryDirectory() as tmpdir:
23-
try:
24-
os.environ["TRITON_CACHE_DIR"] = tmpdir
22+
from triton import knobs
23+
with knobs.cache.scope():
24+
knobs.cache.dir = tmpdir
2525
yield tmpdir
26-
finally:
27-
os.environ.pop("TRITON_CACHE_DIR", None)
2826

2927

3028
def _fresh_knobs_impl(monkeypatch, skipped_attr: Optional[Set[str]] = None):

0 commit comments

Comments
 (0)