Skip to content

Commit 9173a28

Browse files
authored
Merge pull request lightspeed-core#261 from tisnik/refactoring-llama-stack-config-name
LCORE-391: Refactoring: proper Llama Stack config name
2 parents c7ccc96 + 88ecb0b commit 9173a28

6 files changed

Lines changed: 35 additions & 35 deletions

File tree

src/client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
LlamaStackAsLibraryClient, # type: ignore
1010
)
1111
from llama_stack_client import AsyncLlamaStackClient, LlamaStackClient # type: ignore
12-
from models.config import LLamaStackConfiguration
12+
from models.config import LlamaStackConfiguration
1313
from utils.types import Singleton
1414

1515

@@ -21,7 +21,7 @@ class LlamaStackClientHolder(metaclass=Singleton):
2121

2222
_lsc: Optional[LlamaStackClient] = None
2323

24-
def load(self, llama_stack_config: LLamaStackConfiguration) -> None:
24+
def load(self, llama_stack_config: LlamaStackConfiguration) -> None:
2525
"""Retrieve Llama stack client according to configuration."""
2626
if llama_stack_config.use_as_library_client is True:
2727
if llama_stack_config.library_client_config_path is not None:
@@ -57,7 +57,7 @@ class AsyncLlamaStackClientHolder(metaclass=Singleton):
5757

5858
_lsc: Optional[AsyncLlamaStackClient] = None
5959

60-
async def load(self, llama_stack_config: LLamaStackConfiguration) -> None:
60+
async def load(self, llama_stack_config: LlamaStackConfiguration) -> None:
6161
"""Retrieve Async Llama stack client according to configuration."""
6262
if llama_stack_config.use_as_library_client is True:
6363
if llama_stack_config.library_client_config_path is not None:

src/configuration.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from models.config import (
88
Configuration,
99
Customization,
10-
LLamaStackConfiguration,
10+
LlamaStackConfiguration,
1111
UserDataCollection,
1212
ServiceConfiguration,
1313
ModelContextProtocolServer,
@@ -60,7 +60,7 @@ def service_configuration(self) -> ServiceConfiguration:
6060
return self._configuration.service
6161

6262
@property
63-
def llama_stack_configuration(self) -> LLamaStackConfiguration:
63+
def llama_stack_configuration(self) -> LlamaStackConfiguration:
6464
"""Return Llama stack configuration."""
6565
assert (
6666
self._configuration is not None

src/models/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class ModelContextProtocolServer(BaseModel):
5454
url: str
5555

5656

57-
class LLamaStackConfiguration(BaseModel):
57+
class LlamaStackConfiguration(BaseModel):
5858
"""Llama stack configuration."""
5959

6060
url: Optional[str] = None
@@ -174,7 +174,7 @@ class Configuration(BaseModel):
174174

175175
name: str
176176
service: ServiceConfiguration
177-
llama_stack: LLamaStackConfiguration
177+
llama_stack: LlamaStackConfiguration
178178
user_data_collection: UserDataCollection
179179
mcp_servers: list[ModelContextProtocolServer] = []
180180
authentication: Optional[AuthenticationConfiguration] = (

tests/unit/models/test_config.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from models.config import (
1818
AuthenticationConfiguration,
1919
Configuration,
20-
LLamaStackConfiguration,
20+
LlamaStackConfiguration,
2121
ServiceConfiguration,
2222
UserDataCollection,
2323
TLSConfiguration,
@@ -57,20 +57,20 @@ def test_service_configuration_workers_value() -> None:
5757

5858
def test_llama_stack_configuration_constructor() -> None:
5959
"""Test the LLamaStackConfiguration constructor."""
60-
llama_stack_configuration = LLamaStackConfiguration(
60+
llama_stack_configuration = LlamaStackConfiguration(
6161
use_as_library_client=True, library_client_config_path="foo"
6262
)
6363
assert llama_stack_configuration is not None
6464

65-
llama_stack_configuration = LLamaStackConfiguration(
65+
llama_stack_configuration = LlamaStackConfiguration(
6666
use_as_library_client=False, url="http://localhost"
6767
)
6868
assert llama_stack_configuration is not None
6969

70-
llama_stack_configuration = LLamaStackConfiguration(url="http://localhost")
70+
llama_stack_configuration = LlamaStackConfiguration(url="http://localhost")
7171
assert llama_stack_configuration is not None
7272

73-
llama_stack_configuration = LLamaStackConfiguration(
73+
llama_stack_configuration = LlamaStackConfiguration(
7474
use_as_library_client=False, url="http://localhost", api_key="foo"
7575
)
7676
assert llama_stack_configuration is not None
@@ -82,7 +82,7 @@ def test_llama_stack_wrong_configuration_constructor_no_url() -> None:
8282
ValueError,
8383
match="LLama stack URL is not specified and library client mode is not specified",
8484
):
85-
LLamaStackConfiguration()
85+
LlamaStackConfiguration()
8686

8787

8888
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:
9191
ValueError,
9292
match="LLama stack URL is not specified and library client mode is not enabled",
9393
):
94-
LLamaStackConfiguration(use_as_library_client=False)
94+
LlamaStackConfiguration(use_as_library_client=False)
9595

9696

9797
def test_llama_stack_wrong_configuration_no_config_file() -> None:
9898
"""Test the LLamaStackConfiguration constructor."""
9999
m = "LLama stack library client mode is enabled but a configuration file path is not specified"
100100
with pytest.raises(ValueError, match=m):
101-
LLamaStackConfiguration(use_as_library_client=True)
101+
LlamaStackConfiguration(use_as_library_client=True)
102102

103103

104104
def test_user_data_collection_feedback_enabled() -> None:
@@ -297,7 +297,7 @@ def test_configuration_empty_mcp_servers() -> None:
297297
cfg = Configuration(
298298
name="test_name",
299299
service=ServiceConfiguration(),
300-
llama_stack=LLamaStackConfiguration(
300+
llama_stack=LlamaStackConfiguration(
301301
use_as_library_client=True, library_client_config_path="foo"
302302
),
303303
user_data_collection=UserDataCollection(
@@ -318,7 +318,7 @@ def test_configuration_single_mcp_server() -> None:
318318
cfg = Configuration(
319319
name="test_name",
320320
service=ServiceConfiguration(),
321-
llama_stack=LLamaStackConfiguration(
321+
llama_stack=LlamaStackConfiguration(
322322
use_as_library_client=True, library_client_config_path="foo"
323323
),
324324
user_data_collection=UserDataCollection(
@@ -345,7 +345,7 @@ def test_configuration_multiple_mcp_servers() -> None:
345345
cfg = Configuration(
346346
name="test_name",
347347
service=ServiceConfiguration(),
348-
llama_stack=LLamaStackConfiguration(
348+
llama_stack=LlamaStackConfiguration(
349349
use_as_library_client=True, library_client_config_path="foo"
350350
),
351351
user_data_collection=UserDataCollection(
@@ -367,7 +367,7 @@ def test_dump_configuration(tmp_path) -> None:
367367
cfg = Configuration(
368368
name="test_name",
369369
service=ServiceConfiguration(),
370-
llama_stack=LLamaStackConfiguration(
370+
llama_stack=LlamaStackConfiguration(
371371
use_as_library_client=True, library_client_config_path="foo"
372372
),
373373
user_data_collection=UserDataCollection(
@@ -449,7 +449,7 @@ def test_dump_configuration_with_one_mcp_server(tmp_path) -> None:
449449
cfg = Configuration(
450450
name="test_name",
451451
service=ServiceConfiguration(),
452-
llama_stack=LLamaStackConfiguration(
452+
llama_stack=LlamaStackConfiguration(
453453
use_as_library_client=True, library_client_config_path="foo"
454454
),
455455
user_data_collection=UserDataCollection(
@@ -534,7 +534,7 @@ def test_dump_configuration_with_more_mcp_servers(tmp_path) -> None:
534534
cfg = Configuration(
535535
name="test_name",
536536
service=ServiceConfiguration(),
537-
llama_stack=LLamaStackConfiguration(
537+
llama_stack=LlamaStackConfiguration(
538538
use_as_library_client=True, library_client_config_path="foo"
539539
),
540540
user_data_collection=UserDataCollection(

tests/unit/test_client.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
import pytest
44

55
from client import LlamaStackClientHolder, AsyncLlamaStackClientHolder
6-
from models.config import LLamaStackConfiguration
6+
from models.config import LlamaStackConfiguration
77

88

99
def test_get_llama_stack_library_client() -> None:
1010
"""Test if Llama Stack can be initialized in library client mode."""
11-
cfg = LLamaStackConfiguration(
11+
cfg = LlamaStackConfiguration(
1212
url=None,
1313
api_key=None,
1414
use_as_library_client=True,
@@ -21,7 +21,7 @@ def test_get_llama_stack_library_client() -> None:
2121

2222
def test_get_llama_stack_remote_client() -> None:
2323
"""Test if Llama Stack can be initialized in remove client (server) mode."""
24-
cfg = LLamaStackConfiguration(
24+
cfg = LlamaStackConfiguration(
2525
url="http://localhost:8321",
2626
api_key=None,
2727
use_as_library_client=False,
@@ -34,7 +34,7 @@ def test_get_llama_stack_remote_client() -> None:
3434

3535
def test_get_llama_stack_wrong_configuration() -> None:
3636
"""Test if configuration is checked before Llama Stack is initialized."""
37-
cfg = LLamaStackConfiguration(
37+
cfg = LlamaStackConfiguration(
3838
url=None,
3939
api_key=None,
4040
use_as_library_client=True,
@@ -51,7 +51,7 @@ def test_get_llama_stack_wrong_configuration() -> None:
5151

5252
async def test_get_async_llama_stack_library_client() -> None:
5353
"""Test the initialization of asynchronous Llama Stack client in library mode."""
54-
cfg = LLamaStackConfiguration(
54+
cfg = LlamaStackConfiguration(
5555
url=None,
5656
api_key=None,
5757
use_as_library_client=True,
@@ -64,7 +64,7 @@ async def test_get_async_llama_stack_library_client() -> None:
6464

6565
async def test_get_async_llama_stack_remote_client() -> None:
6666
"""Test the initialization of asynchronous Llama Stack client in server mode."""
67-
cfg = LLamaStackConfiguration(
67+
cfg = LlamaStackConfiguration(
6868
url="http://localhost:8321",
6969
api_key=None,
7070
use_as_library_client=False,
@@ -77,7 +77,7 @@ async def test_get_async_llama_stack_remote_client() -> None:
7777

7878
async def test_get_async_llama_stack_wrong_configuration() -> None:
7979
"""Test if configuration is checked before Llama Stack is initialized."""
80-
cfg = LLamaStackConfiguration(
80+
cfg = LlamaStackConfiguration(
8181
url=None,
8282
api_key=None,
8383
use_as_library_client=True,

tests/unit/utils/test_common.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from models.config import (
1313
Configuration,
1414
ServiceConfiguration,
15-
LLamaStackConfiguration,
15+
LlamaStackConfiguration,
1616
UserDataCollection,
1717
ModelContextProtocolServer,
1818
)
@@ -38,7 +38,7 @@ async def test_register_mcp_servers_empty_list(mocker):
3838
config = Configuration(
3939
name="test",
4040
service=ServiceConfiguration(),
41-
llama_stack=LLamaStackConfiguration(
41+
llama_stack=LlamaStackConfiguration(
4242
use_as_library_client=False, url="http://localhost:8321"
4343
),
4444
user_data_collection=UserDataCollection(feedback_disabled=True),
@@ -78,7 +78,7 @@ async def test_register_mcp_servers_single_server_not_registered(mocker):
7878
config = Configuration(
7979
name="test",
8080
service=ServiceConfiguration(),
81-
llama_stack=LLamaStackConfiguration(
81+
llama_stack=LlamaStackConfiguration(
8282
use_as_library_client=False, url="http://localhost:8321"
8383
),
8484
user_data_collection=UserDataCollection(feedback_disabled=True),
@@ -122,7 +122,7 @@ async def test_register_mcp_servers_single_server_already_registered(mocker):
122122
config = Configuration(
123123
name="test",
124124
service=ServiceConfiguration(),
125-
llama_stack=LLamaStackConfiguration(
125+
llama_stack=LlamaStackConfiguration(
126126
use_as_library_client=False, url="http://localhost:8321"
127127
),
128128
user_data_collection=UserDataCollection(feedback_disabled=True),
@@ -169,7 +169,7 @@ async def test_register_mcp_servers_multiple_servers_mixed_registration(mocker):
169169
config = Configuration(
170170
name="test",
171171
service=ServiceConfiguration(),
172-
llama_stack=LLamaStackConfiguration(
172+
llama_stack=LlamaStackConfiguration(
173173
use_as_library_client=False, url="http://localhost:8321"
174174
),
175175
user_data_collection=UserDataCollection(feedback_disabled=True),
@@ -223,7 +223,7 @@ async def test_register_mcp_servers_with_custom_provider(mocker):
223223
config = Configuration(
224224
name="test",
225225
service=ServiceConfiguration(),
226-
llama_stack=LLamaStackConfiguration(
226+
llama_stack=LlamaStackConfiguration(
227227
use_as_library_client=False, url="http://localhost:8321"
228228
),
229229
user_data_collection=UserDataCollection(feedback_disabled=True),
@@ -267,7 +267,7 @@ async def test_register_mcp_servers_async_with_library_client(mocker):
267267
config = Configuration(
268268
name="test",
269269
service=ServiceConfiguration(),
270-
llama_stack=LLamaStackConfiguration(
270+
llama_stack=LlamaStackConfiguration(
271271
use_as_library_client=True,
272272
library_client_config_path="/path/to/config.yaml",
273273
),

0 commit comments

Comments
 (0)