mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-12-03 09:53:45 +00:00
fix(tests): reduce some test noise (#3825)
a bunch of logger.info()s are good for server code to help debug in production, but we don't want them killing our unit test output :) --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
parent
0c368492b7
commit
07fc8013eb
5 changed files with 26 additions and 25 deletions
|
|
@ -550,7 +550,7 @@ class OpenAIVectorStoreMixin(ABC):
|
||||||
logger.info(f"Using default embedding model: {model_id} with dimension {embedding_dimension}")
|
logger.info(f"Using default embedding model: {model_id} with dimension {embedding_dimension}")
|
||||||
return model_id, embedding_dimension
|
return model_id, embedding_dimension
|
||||||
|
|
||||||
logger.info("DEBUG: No default embedding models found")
|
logger.debug("No default embedding models found")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
async def openai_list_vector_stores(
|
async def openai_list_vector_stores(
|
||||||
|
|
|
||||||
|
|
@ -329,3 +329,4 @@ classmethod-decorators = ["classmethod", "pydantic.field_validator"]
|
||||||
addopts = ["--durations=10"]
|
addopts = ["--durations=10"]
|
||||||
asyncio_mode = "auto"
|
asyncio_mode = "auto"
|
||||||
markers = ["allow_network: Allow network access for specific unit tests"]
|
markers = ["allow_network: Allow network access for specific unit tests"]
|
||||||
|
filterwarnings = "ignore::DeprecationWarning"
|
||||||
|
|
|
||||||
|
|
@ -4,17 +4,17 @@
|
||||||
# This source code is licensed under the terms described in the LICENSE file in
|
# This source code is licensed under the terms described in the LICENSE file in
|
||||||
# the root directory of this source tree.
|
# the root directory of this source tree.
|
||||||
|
|
||||||
import pytest_socket
|
import os
|
||||||
|
import warnings
|
||||||
# We need to import the fixtures here so that pytest can find them
|
|
||||||
# but ruff doesn't think they are used and removes the import. "noqa: F401" prevents them from being removed
|
|
||||||
from .fixtures import cached_disk_dist_registry, disk_dist_registry, sqlite_kvstore # noqa: F401
|
|
||||||
|
|
||||||
|
|
||||||
def pytest_runtest_setup(item):
|
def pytest_sessionstart(session) -> None:
|
||||||
"""Setup for each test - check if network access should be allowed."""
|
if "LLAMA_STACK_LOGGING" not in os.environ:
|
||||||
if "allow_network" in item.keywords:
|
os.environ["LLAMA_STACK_LOGGING"] = "all=WARNING"
|
||||||
pytest_socket.enable_socket()
|
|
||||||
else:
|
# Silence common deprecation spam during unit tests.
|
||||||
# Allowing Unix sockets is necessary for some tests that use local servers and mocks
|
warnings.filterwarnings("ignore", category=DeprecationWarning)
|
||||||
pytest_socket.disable_socket(allow_unix_socket=True)
|
warnings.filterwarnings("ignore", category=PendingDeprecationWarning)
|
||||||
|
|
||||||
|
|
||||||
|
pytest_plugins = ["tests.unit.fixtures"]
|
||||||
|
|
|
||||||
|
|
@ -15,16 +15,16 @@ from llama_stack.providers.utils.inference.litellm_openai_mixin import LiteLLMOp
|
||||||
|
|
||||||
|
|
||||||
# Test fixtures and helper classes
|
# Test fixtures and helper classes
|
||||||
class TestConfig(BaseModel):
|
class FakeConfig(BaseModel):
|
||||||
api_key: str | None = Field(default=None)
|
api_key: str | None = Field(default=None)
|
||||||
|
|
||||||
|
|
||||||
class TestProviderDataValidator(BaseModel):
|
class FakeProviderDataValidator(BaseModel):
|
||||||
test_api_key: str | None = Field(default=None)
|
test_api_key: str | None = Field(default=None)
|
||||||
|
|
||||||
|
|
||||||
class TestLiteLLMAdapter(LiteLLMOpenAIMixin):
|
class FakeLiteLLMAdapter(LiteLLMOpenAIMixin):
|
||||||
def __init__(self, config: TestConfig):
|
def __init__(self, config: FakeConfig):
|
||||||
super().__init__(
|
super().__init__(
|
||||||
litellm_provider_name="test",
|
litellm_provider_name="test",
|
||||||
api_key_from_config=config.api_key,
|
api_key_from_config=config.api_key,
|
||||||
|
|
@ -36,11 +36,11 @@ class TestLiteLLMAdapter(LiteLLMOpenAIMixin):
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def adapter_with_config_key():
|
def adapter_with_config_key():
|
||||||
"""Fixture to create adapter with API key in config"""
|
"""Fixture to create adapter with API key in config"""
|
||||||
config = TestConfig(api_key="config-api-key")
|
config = FakeConfig(api_key="config-api-key")
|
||||||
adapter = TestLiteLLMAdapter(config)
|
adapter = FakeLiteLLMAdapter(config)
|
||||||
adapter.__provider_spec__ = MagicMock()
|
adapter.__provider_spec__ = MagicMock()
|
||||||
adapter.__provider_spec__.provider_data_validator = (
|
adapter.__provider_spec__.provider_data_validator = (
|
||||||
"tests.unit.providers.inference.test_litellm_openai_mixin.TestProviderDataValidator"
|
"tests.unit.providers.inference.test_litellm_openai_mixin.FakeProviderDataValidator"
|
||||||
)
|
)
|
||||||
return adapter
|
return adapter
|
||||||
|
|
||||||
|
|
@ -48,11 +48,11 @@ def adapter_with_config_key():
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def adapter_without_config_key():
|
def adapter_without_config_key():
|
||||||
"""Fixture to create adapter without API key in config"""
|
"""Fixture to create adapter without API key in config"""
|
||||||
config = TestConfig(api_key=None)
|
config = FakeConfig(api_key=None)
|
||||||
adapter = TestLiteLLMAdapter(config)
|
adapter = FakeLiteLLMAdapter(config)
|
||||||
adapter.__provider_spec__ = MagicMock()
|
adapter.__provider_spec__ = MagicMock()
|
||||||
adapter.__provider_spec__.provider_data_validator = (
|
adapter.__provider_spec__.provider_data_validator = (
|
||||||
"tests.unit.providers.inference.test_litellm_openai_mixin.TestProviderDataValidator"
|
"tests.unit.providers.inference.test_litellm_openai_mixin.FakeProviderDataValidator"
|
||||||
)
|
)
|
||||||
return adapter
|
return adapter
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ from llama_stack.providers.remote.safety.nvidia.config import NVIDIASafetyConfig
|
||||||
from llama_stack.providers.remote.safety.nvidia.nvidia import NVIDIASafetyAdapter
|
from llama_stack.providers.remote.safety.nvidia.nvidia import NVIDIASafetyAdapter
|
||||||
|
|
||||||
|
|
||||||
class TestNVIDIASafetyAdapter(NVIDIASafetyAdapter):
|
class FakeNVIDIASafetyAdapter(NVIDIASafetyAdapter):
|
||||||
"""Test implementation that provides the required shield_store."""
|
"""Test implementation that provides the required shield_store."""
|
||||||
|
|
||||||
def __init__(self, config: NVIDIASafetyConfig, shield_store):
|
def __init__(self, config: NVIDIASafetyConfig, shield_store):
|
||||||
|
|
@ -41,7 +41,7 @@ def nvidia_adapter():
|
||||||
shield_store = AsyncMock()
|
shield_store = AsyncMock()
|
||||||
shield_store.get_shield = AsyncMock()
|
shield_store.get_shield = AsyncMock()
|
||||||
|
|
||||||
adapter = TestNVIDIASafetyAdapter(config=config, shield_store=shield_store)
|
adapter = FakeNVIDIASafetyAdapter(config=config, shield_store=shield_store)
|
||||||
|
|
||||||
return adapter
|
return adapter
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue