diff --git a/llama_stack/providers/inline/telemetry/sample/config.py b/llama_stack/providers/inline/telemetry/sample/config.py index 4b7404a26..fce8dc5fd 100644 --- a/llama_stack/providers/inline/telemetry/sample/config.py +++ b/llama_stack/providers/inline/telemetry/sample/config.py @@ -4,9 +4,18 @@ # This source code is licensed under the terms described in the LICENSE file in # the root directory of this source tree. +from typing import Any, Dict + from pydantic import BaseModel class SampleConfig(BaseModel): host: str = "localhost" port: int = 9999 + + @classmethod + def sample_run_config(cls, __distro_dir__: str, **kwargs: Any) -> Dict[str, Any]: + return { + "host": "localhost", + "port": 9999, + } diff --git a/llama_stack/providers/remote/agents/sample/config.py b/llama_stack/providers/remote/agents/sample/config.py index 4b7404a26..fce8dc5fd 100644 --- a/llama_stack/providers/remote/agents/sample/config.py +++ b/llama_stack/providers/remote/agents/sample/config.py @@ -4,9 +4,18 @@ # This source code is licensed under the terms described in the LICENSE file in # the root directory of this source tree. +from typing import Any, Dict + from pydantic import BaseModel class SampleConfig(BaseModel): host: str = "localhost" port: int = 9999 + + @classmethod + def sample_run_config(cls, __distro_dir__: str, **kwargs: Any) -> Dict[str, Any]: + return { + "host": "localhost", + "port": 9999, + } diff --git a/llama_stack/providers/remote/inference/sample/config.py b/llama_stack/providers/remote/inference/sample/config.py index 4b7404a26..fce8dc5fd 100644 --- a/llama_stack/providers/remote/inference/sample/config.py +++ b/llama_stack/providers/remote/inference/sample/config.py @@ -4,9 +4,18 @@ # This source code is licensed under the terms described in the LICENSE file in # the root directory of this source tree. +from typing import Any, Dict + from pydantic import BaseModel class SampleConfig(BaseModel): host: str = "localhost" port: int = 9999 + + @classmethod + def sample_run_config(cls, __distro_dir__: str, **kwargs: Any) -> Dict[str, Any]: + return { + "host": "localhost", + "port": 9999, + } diff --git a/llama_stack/providers/remote/safety/sample/config.py b/llama_stack/providers/remote/safety/sample/config.py index 4b7404a26..fce8dc5fd 100644 --- a/llama_stack/providers/remote/safety/sample/config.py +++ b/llama_stack/providers/remote/safety/sample/config.py @@ -4,9 +4,18 @@ # This source code is licensed under the terms described in the LICENSE file in # the root directory of this source tree. +from typing import Any, Dict + from pydantic import BaseModel class SampleConfig(BaseModel): host: str = "localhost" port: int = 9999 + + @classmethod + def sample_run_config(cls, __distro_dir__: str, **kwargs: Any) -> Dict[str, Any]: + return { + "host": "localhost", + "port": 9999, + } diff --git a/llama_stack/providers/remote/vector_io/sample/config.py b/llama_stack/providers/remote/vector_io/sample/config.py index 5126e5eff..00170dbdb 100644 --- a/llama_stack/providers/remote/vector_io/sample/config.py +++ b/llama_stack/providers/remote/vector_io/sample/config.py @@ -4,9 +4,18 @@ # This source code is licensed under the terms described in the LICENSE file in # the root directory of this source tree. +from typing import Any, Dict + from pydantic import BaseModel class SampleVectorIOConfig(BaseModel): host: str = "localhost" port: int = 9999 + + @classmethod + def sample_run_config(cls, __distro_dir__: str, **kwargs: Any) -> Dict[str, Any]: + return { + "host": "localhost", + "port": 9999, + } diff --git a/tests/unit/providers/test_configs.py b/tests/unit/providers/test_configs.py index c284e682f..fa5773493 100644 --- a/tests/unit/providers/test_configs.py +++ b/tests/unit/providers/test_configs.py @@ -13,8 +13,9 @@ from llama_stack.distribution.utils.dynamic import instantiate_class_type def test_all_provider_configs_can_be_instantiated(): """ - Test that all provider configs can be instantiated. - This ensures that all config classes are correctly defined and can be instantiated without errors. + Test that all provider configs can be instantiated "lightly". If a config class ends up + importing the implementation class, this will likely fail because we don't run unit tests + with tons of dependencies. """ # Get all provider registries provider_registry = get_provider_registry() @@ -34,6 +35,11 @@ def test_all_provider_configs_can_be_instantiated(): config_type = instantiate_class_type(config_class_name) assert issubclass(config_type, BaseModel) + assert hasattr(config_type, "sample_run_config"), ( + f"{config_class_name} does not have sample_run_config method" + ) + sample_config = config_type.sample_run_config(__distro_dir__="foobarbaz") + assert isinstance(sample_config, dict) except Exception as e: failures.append(f"Failed to instantiate {provider_type} config: {str(e)}")