Skip to content

Commit e90fe25

Browse files
authored
fix(tests): move llama stack client init back to fixture (#3071)
See inline comments
1 parent 5f1ddd3 commit e90fe25

File tree

2 files changed

+7
-19
lines changed

2 files changed

+7
-19
lines changed

tests/integration/conftest.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,12 @@
99
import platform
1010
import textwrap
1111
import time
12-
import warnings
1312

1413
import pytest
1514
from dotenv import load_dotenv
1615

1716
from llama_stack.log import get_logger
1817

19-
from .fixtures.common import instantiate_llama_stack_client
20-
2118
logger = get_logger(__name__, category="tests")
2219

2320

@@ -34,20 +31,6 @@ def pytest_sessionstart(session):
3431
# stop macOS from complaining about duplicate OpenMP libraries
3532
os.environ["KMP_DUPLICATE_LIB_OK"] = "TRUE"
3633

37-
# pull client instantiation to session start so all the complex logs during initialization
38-
# don't clobber the test one-liner outputs
39-
print("instantiating llama_stack_client")
40-
start_time = time.time()
41-
with warnings.catch_warnings():
42-
warnings.filterwarnings("ignore", category=DeprecationWarning)
43-
44-
try:
45-
session._llama_stack_client = instantiate_llama_stack_client(session)
46-
except Exception as e:
47-
logger.error(f"Error instantiating llama_stack_client: {e}")
48-
session._llama_stack_client = None
49-
print(f"llama_stack_client instantiated in {time.time() - start_time:.3f}s")
50-
5134

5235
def pytest_runtest_teardown(item):
5336
# Check if the test actually ran and passed or failed, but was not skipped or an expected failure (xfail)

tests/integration/fixtures/common.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,13 @@ def skip_if_no_model(request):
178178

179179
@pytest.fixture(scope="session")
180180
def llama_stack_client(request):
181-
client = request.session._llama_stack_client
182-
assert client is not None, "llama_stack_client not found in session cache"
181+
# ideally, we could do this in session start given all the complex logs during initialization
182+
# don't clobber the test one-liner outputs. however, this also means all tests in a sub-directory
183+
# would be forced to use llama_stack_client, which is not what we want.
184+
print("\ninstantiating llama_stack_client")
185+
start_time = time.time()
186+
client = instantiate_llama_stack_client(request.session)
187+
print(f"llama_stack_client instantiated in {time.time() - start_time:.3f}s")
183188
return client
184189

185190

0 commit comments

Comments
 (0)