From 88ecb0b0cf569178b4b1695de190cce4f9b3ffe6 Mon Sep 17 00:00:00 2001 From: Pavel Tisnovsky Date: Sun, 20 Jul 2025 20:35:46 +0200 Subject: [PATCH] Refactoring: proper Llama Stack config name --- src/client.py | 6 +++--- src/configuration.py | 4 ++-- src/models/config.py | 4 ++-- tests/unit/models/test_config.py | 28 ++++++++++++++-------------- tests/unit/test_client.py | 14 +++++++------- tests/unit/utils/test_common.py | 14 +++++++------- 6 files changed, 35 insertions(+), 35 deletions(-) diff --git a/src/client.py b/src/client.py index d01b0411..93415008 100644 --- a/src/client.py +++ b/src/client.py @@ -9,7 +9,7 @@ LlamaStackAsLibraryClient, # type: ignore ) from llama_stack_client import AsyncLlamaStackClient, LlamaStackClient # type: ignore -from models.config import LLamaStackConfiguration +from models.config import LlamaStackConfiguration from utils.types import Singleton @@ -21,7 +21,7 @@ class LlamaStackClientHolder(metaclass=Singleton): _lsc: Optional[LlamaStackClient] = None - def load(self, llama_stack_config: LLamaStackConfiguration) -> None: + def load(self, llama_stack_config: LlamaStackConfiguration) -> None: """Retrieve Llama stack client according to configuration.""" if llama_stack_config.use_as_library_client is True: if llama_stack_config.library_client_config_path is not None: @@ -57,7 +57,7 @@ class AsyncLlamaStackClientHolder(metaclass=Singleton): _lsc: Optional[AsyncLlamaStackClient] = None - async def load(self, llama_stack_config: LLamaStackConfiguration) -> None: + async def load(self, llama_stack_config: LlamaStackConfiguration) -> None: """Retrieve Async Llama stack client according to configuration.""" if llama_stack_config.use_as_library_client is True: if llama_stack_config.library_client_config_path is not None: diff --git a/src/configuration.py b/src/configuration.py index 137d304a..21eca543 100644 --- a/src/configuration.py +++ b/src/configuration.py @@ -7,7 +7,7 @@ from models.config import ( Configuration, Customization, - LLamaStackConfiguration, + LlamaStackConfiguration, UserDataCollection, ServiceConfiguration, ModelContextProtocolServer, @@ -60,7 +60,7 @@ def service_configuration(self) -> ServiceConfiguration: return self._configuration.service @property - def llama_stack_configuration(self) -> LLamaStackConfiguration: + def llama_stack_configuration(self) -> LlamaStackConfiguration: """Return Llama stack configuration.""" assert ( self._configuration is not None diff --git a/src/models/config.py b/src/models/config.py index 8e2d36e3..1b923728 100644 --- a/src/models/config.py +++ b/src/models/config.py @@ -54,7 +54,7 @@ class ModelContextProtocolServer(BaseModel): url: str -class LLamaStackConfiguration(BaseModel): +class LlamaStackConfiguration(BaseModel): """Llama stack configuration.""" url: Optional[str] = None @@ -174,7 +174,7 @@ class Configuration(BaseModel): name: str service: ServiceConfiguration - llama_stack: LLamaStackConfiguration + llama_stack: LlamaStackConfiguration user_data_collection: UserDataCollection mcp_servers: list[ModelContextProtocolServer] = [] authentication: Optional[AuthenticationConfiguration] = ( diff --git a/tests/unit/models/test_config.py b/tests/unit/models/test_config.py index fc07f81e..376fbbf1 100644 --- a/tests/unit/models/test_config.py +++ b/tests/unit/models/test_config.py @@ -17,7 +17,7 @@ from models.config import ( AuthenticationConfiguration, Configuration, - LLamaStackConfiguration, + LlamaStackConfiguration, ServiceConfiguration, UserDataCollection, TLSConfiguration, @@ -57,20 +57,20 @@ def test_service_configuration_workers_value() -> None: def test_llama_stack_configuration_constructor() -> None: """Test the LLamaStackConfiguration constructor.""" - llama_stack_configuration = LLamaStackConfiguration( + llama_stack_configuration = LlamaStackConfiguration( use_as_library_client=True, library_client_config_path="foo" ) assert llama_stack_configuration is not None - llama_stack_configuration = LLamaStackConfiguration( + llama_stack_configuration = LlamaStackConfiguration( use_as_library_client=False, url="http://localhost" ) assert llama_stack_configuration is not None - llama_stack_configuration = LLamaStackConfiguration(url="http://localhost") + llama_stack_configuration = LlamaStackConfiguration(url="http://localhost") assert llama_stack_configuration is not None - llama_stack_configuration = LLamaStackConfiguration( + llama_stack_configuration = LlamaStackConfiguration( use_as_library_client=False, url="http://localhost", api_key="foo" ) assert llama_stack_configuration is not None @@ -82,7 +82,7 @@ def test_llama_stack_wrong_configuration_constructor_no_url() -> None: ValueError, match="LLama stack URL is not specified and library client mode is not specified", ): - LLamaStackConfiguration() + LlamaStackConfiguration() def test_llama_stack_wrong_configuration_constructor_library_mode_off() -> None: @@ -91,14 +91,14 @@ def test_llama_stack_wrong_configuration_constructor_library_mode_off() -> None: ValueError, match="LLama stack URL is not specified and library client mode is not enabled", ): - LLamaStackConfiguration(use_as_library_client=False) + LlamaStackConfiguration(use_as_library_client=False) def test_llama_stack_wrong_configuration_no_config_file() -> None: """Test the LLamaStackConfiguration constructor.""" m = "LLama stack library client mode is enabled but a configuration file path is not specified" with pytest.raises(ValueError, match=m): - LLamaStackConfiguration(use_as_library_client=True) + LlamaStackConfiguration(use_as_library_client=True) def test_user_data_collection_feedback_enabled() -> None: @@ -297,7 +297,7 @@ def test_configuration_empty_mcp_servers() -> None: cfg = Configuration( name="test_name", service=ServiceConfiguration(), - llama_stack=LLamaStackConfiguration( + llama_stack=LlamaStackConfiguration( use_as_library_client=True, library_client_config_path="foo" ), user_data_collection=UserDataCollection( @@ -318,7 +318,7 @@ def test_configuration_single_mcp_server() -> None: cfg = Configuration( name="test_name", service=ServiceConfiguration(), - llama_stack=LLamaStackConfiguration( + llama_stack=LlamaStackConfiguration( use_as_library_client=True, library_client_config_path="foo" ), user_data_collection=UserDataCollection( @@ -345,7 +345,7 @@ def test_configuration_multiple_mcp_servers() -> None: cfg = Configuration( name="test_name", service=ServiceConfiguration(), - llama_stack=LLamaStackConfiguration( + llama_stack=LlamaStackConfiguration( use_as_library_client=True, library_client_config_path="foo" ), user_data_collection=UserDataCollection( @@ -367,7 +367,7 @@ def test_dump_configuration(tmp_path) -> None: cfg = Configuration( name="test_name", service=ServiceConfiguration(), - llama_stack=LLamaStackConfiguration( + llama_stack=LlamaStackConfiguration( use_as_library_client=True, library_client_config_path="foo" ), user_data_collection=UserDataCollection( @@ -449,7 +449,7 @@ def test_dump_configuration_with_one_mcp_server(tmp_path) -> None: cfg = Configuration( name="test_name", service=ServiceConfiguration(), - llama_stack=LLamaStackConfiguration( + llama_stack=LlamaStackConfiguration( use_as_library_client=True, library_client_config_path="foo" ), user_data_collection=UserDataCollection( @@ -534,7 +534,7 @@ def test_dump_configuration_with_more_mcp_servers(tmp_path) -> None: cfg = Configuration( name="test_name", service=ServiceConfiguration(), - llama_stack=LLamaStackConfiguration( + llama_stack=LlamaStackConfiguration( use_as_library_client=True, library_client_config_path="foo" ), user_data_collection=UserDataCollection( diff --git a/tests/unit/test_client.py b/tests/unit/test_client.py index 97b1e555..eab575e7 100644 --- a/tests/unit/test_client.py +++ b/tests/unit/test_client.py @@ -3,12 +3,12 @@ import pytest from client import LlamaStackClientHolder, AsyncLlamaStackClientHolder -from models.config import LLamaStackConfiguration +from models.config import LlamaStackConfiguration def test_get_llama_stack_library_client() -> None: """Test if Llama Stack can be initialized in library client mode.""" - cfg = LLamaStackConfiguration( + cfg = LlamaStackConfiguration( url=None, api_key=None, use_as_library_client=True, @@ -21,7 +21,7 @@ def test_get_llama_stack_library_client() -> None: def test_get_llama_stack_remote_client() -> None: """Test if Llama Stack can be initialized in remove client (server) mode.""" - cfg = LLamaStackConfiguration( + cfg = LlamaStackConfiguration( url="http://localhost:8321", api_key=None, use_as_library_client=False, @@ -34,7 +34,7 @@ def test_get_llama_stack_remote_client() -> None: def test_get_llama_stack_wrong_configuration() -> None: """Test if configuration is checked before Llama Stack is initialized.""" - cfg = LLamaStackConfiguration( + cfg = LlamaStackConfiguration( url=None, api_key=None, use_as_library_client=True, @@ -51,7 +51,7 @@ def test_get_llama_stack_wrong_configuration() -> None: async def test_get_async_llama_stack_library_client() -> None: """Test the initialization of asynchronous Llama Stack client in library mode.""" - cfg = LLamaStackConfiguration( + cfg = LlamaStackConfiguration( url=None, api_key=None, use_as_library_client=True, @@ -64,7 +64,7 @@ async def test_get_async_llama_stack_library_client() -> None: async def test_get_async_llama_stack_remote_client() -> None: """Test the initialization of asynchronous Llama Stack client in server mode.""" - cfg = LLamaStackConfiguration( + cfg = LlamaStackConfiguration( url="http://localhost:8321", api_key=None, use_as_library_client=False, @@ -77,7 +77,7 @@ async def test_get_async_llama_stack_remote_client() -> None: async def test_get_async_llama_stack_wrong_configuration() -> None: """Test if configuration is checked before Llama Stack is initialized.""" - cfg = LLamaStackConfiguration( + cfg = LlamaStackConfiguration( url=None, api_key=None, use_as_library_client=True, diff --git a/tests/unit/utils/test_common.py b/tests/unit/utils/test_common.py index 0b34e0de..8a0b845f 100644 --- a/tests/unit/utils/test_common.py +++ b/tests/unit/utils/test_common.py @@ -12,7 +12,7 @@ from models.config import ( Configuration, ServiceConfiguration, - LLamaStackConfiguration, + LlamaStackConfiguration, UserDataCollection, ModelContextProtocolServer, ) @@ -38,7 +38,7 @@ async def test_register_mcp_servers_empty_list(mocker): config = Configuration( name="test", service=ServiceConfiguration(), - llama_stack=LLamaStackConfiguration( + llama_stack=LlamaStackConfiguration( use_as_library_client=False, url="http://localhost:8321" ), user_data_collection=UserDataCollection(feedback_disabled=True), @@ -78,7 +78,7 @@ async def test_register_mcp_servers_single_server_not_registered(mocker): config = Configuration( name="test", service=ServiceConfiguration(), - llama_stack=LLamaStackConfiguration( + llama_stack=LlamaStackConfiguration( use_as_library_client=False, url="http://localhost:8321" ), user_data_collection=UserDataCollection(feedback_disabled=True), @@ -122,7 +122,7 @@ async def test_register_mcp_servers_single_server_already_registered(mocker): config = Configuration( name="test", service=ServiceConfiguration(), - llama_stack=LLamaStackConfiguration( + llama_stack=LlamaStackConfiguration( use_as_library_client=False, url="http://localhost:8321" ), user_data_collection=UserDataCollection(feedback_disabled=True), @@ -169,7 +169,7 @@ async def test_register_mcp_servers_multiple_servers_mixed_registration(mocker): config = Configuration( name="test", service=ServiceConfiguration(), - llama_stack=LLamaStackConfiguration( + llama_stack=LlamaStackConfiguration( use_as_library_client=False, url="http://localhost:8321" ), user_data_collection=UserDataCollection(feedback_disabled=True), @@ -223,7 +223,7 @@ async def test_register_mcp_servers_with_custom_provider(mocker): config = Configuration( name="test", service=ServiceConfiguration(), - llama_stack=LLamaStackConfiguration( + llama_stack=LlamaStackConfiguration( use_as_library_client=False, url="http://localhost:8321" ), user_data_collection=UserDataCollection(feedback_disabled=True), @@ -267,7 +267,7 @@ async def test_register_mcp_servers_async_with_library_client(mocker): config = Configuration( name="test", service=ServiceConfiguration(), - llama_stack=LLamaStackConfiguration( + llama_stack=LlamaStackConfiguration( use_as_library_client=True, library_client_config_path="/path/to/config.yaml", ),