From d3d9d146508bec36a7f56b1ffb292f5fcc0a71f8 Mon Sep 17 00:00:00 2001 From: JR Boos Date: Mon, 9 Jun 2025 15:54:30 -0400 Subject: [PATCH 1/4] Fixed Unit Test --- tests/configuration/minimal-stack.yaml | 6 ++++++ tests/unit/test_client.py | 9 +++++---- 2 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 tests/configuration/minimal-stack.yaml diff --git a/tests/configuration/minimal-stack.yaml b/tests/configuration/minimal-stack.yaml new file mode 100644 index 00000000..0b9a8a35 --- /dev/null +++ b/tests/configuration/minimal-stack.yaml @@ -0,0 +1,6 @@ +version: '2' +image_name: llamastack-minimal-stack +container_image: null + +apis: [] +providers: {} diff --git a/tests/unit/test_client.py b/tests/unit/test_client.py index ba016e5b..171fbdc4 100644 --- a/tests/unit/test_client.py +++ b/tests/unit/test_client.py @@ -10,13 +10,14 @@ # [tisnik] Need to resolve dependencies on CI to be able to run this tests @patch.dict(os.environ, {"INFERENCE_MODEL": "llama3.2:3b-instruct-fp16"}) -def _test_get_llama_stack_library_client() -> None: +def test_get_llama_stack_library_client() -> None: cfg = LLamaStackConfiguration( url=None, api_key=None, use_as_library_client=True, - library_client_config_path="ollama", + library_client_config_path="./tests/configuration/minimal-stack.yaml", ) + client = get_llama_stack_client(cfg) assert client is not None @@ -27,7 +28,7 @@ def test_get_llama_stack_remote_client() -> None: url="http://localhost:8321", api_key=None, use_as_library_client=False, - library_client_config_path="ollama", + library_client_config_path="./tests/configuration/minimal-stack.yaml", ) client = get_llama_stack_client(cfg) assert client is not None @@ -39,7 +40,7 @@ def test_get_llama_stack_wrong_configuration() -> None: url=None, api_key=None, use_as_library_client=True, - library_client_config_path="ollama", + library_client_config_path="./tests/configuration/minimal-stack.yaml", ) cfg.library_client_config_path = None with pytest.raises( From 6ff55989c14a06c5c9eab96ff2cc0e21e6213fc5 Mon Sep 17 00:00:00 2001 From: JR Boos Date: Mon, 9 Jun 2025 16:10:09 -0400 Subject: [PATCH 2/4] Added Sqlite (Required to pass unit tests) --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 3999f470..9de2bda8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,6 +30,7 @@ dev = [ "mypy>=1.16.0", "types-PyYAML>=6.0.2", "ruff>=0.11.13", + "aiosqlite", ] [tool.pytest.ini_options] From 6f4ebbd51f246bae251ce86035dff5dd0b770ddb Mon Sep 17 00:00:00 2001 From: JR Boos Date: Mon, 9 Jun 2025 16:14:46 -0400 Subject: [PATCH 3/4] Removed Environment Varaibles --- tests/unit/test_client.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/unit/test_client.py b/tests/unit/test_client.py index 171fbdc4..0c0b6b2c 100644 --- a/tests/unit/test_client.py +++ b/tests/unit/test_client.py @@ -9,7 +9,6 @@ # [tisnik] Need to resolve dependencies on CI to be able to run this tests -@patch.dict(os.environ, {"INFERENCE_MODEL": "llama3.2:3b-instruct-fp16"}) def test_get_llama_stack_library_client() -> None: cfg = LLamaStackConfiguration( url=None, @@ -22,7 +21,6 @@ def test_get_llama_stack_library_client() -> None: assert client is not None -@patch.dict(os.environ, {"INFERENCE_MODEL": "llama3.2:3b-instruct-fp16"}) def test_get_llama_stack_remote_client() -> None: cfg = LLamaStackConfiguration( url="http://localhost:8321", @@ -34,7 +32,6 @@ def test_get_llama_stack_remote_client() -> None: assert client is not None -@patch.dict(os.environ, {"INFERENCE_MODEL": "llama3.2:3b-instruct-fp16"}) def test_get_llama_stack_wrong_configuration() -> None: cfg = LLamaStackConfiguration( url=None, From 5b072dfd1824bf3aab4ad2ae8b14e18a9bc132b3 Mon Sep 17 00:00:00 2001 From: JR Boos Date: Mon, 9 Jun 2025 16:19:55 -0400 Subject: [PATCH 4/4] Fixed Ruff --- pdm.lock | 16 +++++++++++++++- tests/unit/test_client.py | 2 -- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/pdm.lock b/pdm.lock index 9c96bb98..8f48e37e 100644 --- a/pdm.lock +++ b/pdm.lock @@ -5,7 +5,7 @@ groups = ["default", "dev"] strategy = ["inherit_metadata"] lock_version = "4.5.0" -content_hash = "sha256:ddc6729ca7e479d4260806c2d960487f750aa598b025763a771c9563ac84e7ff" +content_hash = "sha256:910b28fc47a38a82cf708002e2acd98de248bbe659eb0ca2e78b6d210eeba7c6" [[metadata.targets]] requires_python = ">=3.11.1,<=3.12.10" @@ -89,6 +89,20 @@ files = [ {file = "aiosignal-1.3.2.tar.gz", hash = "sha256:a8c255c66fafb1e499c9351d0bf32ff2d8a0321595ebac3b93713656d2436f54"}, ] +[[package]] +name = "aiosqlite" +version = "0.21.0" +requires_python = ">=3.9" +summary = "asyncio bridge to the standard sqlite3 module" +groups = ["dev"] +dependencies = [ + "typing-extensions>=4.0", +] +files = [ + {file = "aiosqlite-0.21.0-py3-none-any.whl", hash = "sha256:2549cf4057f95f53dcba16f2b64e8e2791d7e1adedb13197dd8ed77bb226d7d0"}, + {file = "aiosqlite-0.21.0.tar.gz", hash = "sha256:131bb8056daa3bc875608c631c678cda73922a2d4ba8aec373b19f18c17e7aa3"}, +] + [[package]] name = "annotated-types" version = "0.7.0" diff --git a/tests/unit/test_client.py b/tests/unit/test_client.py index 0c0b6b2c..70a0835d 100644 --- a/tests/unit/test_client.py +++ b/tests/unit/test_client.py @@ -1,8 +1,6 @@ """Unit tests for functions defined in src/client.py.""" -import os import pytest -from unittest.mock import patch from client import get_llama_stack_client from models.config import LLamaStackConfiguration