Skip to content

Commit 05c976c

Browse files
RHAIENG-191 - Use LlamaStackDistribution from openshift wrappers (#467)
* RHAIENG-191 - Use LlamaStackDistribution from openshift wrappers * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent e4ea5fb commit 05c976c

File tree

2 files changed

+6
-38
lines changed

2 files changed

+6
-38
lines changed

tests/rag/conftest.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@
1111
from ocp_resources.namespace import Namespace
1212
from ocp_resources.project_project_openshift_io import Project
1313
from simple_logger.logger import get_logger
14-
from timeout_sampler import TimeoutSampler, retry
14+
from timeout_sampler import retry
1515

1616
from utilities.constants import DscComponents, Timeout
1717
from utilities.data_science_cluster_utils import update_components_in_dsc
1818
from utilities.general import generate_random_name
1919
from utilities.infra import create_ns
20-
from utilities.rag_utils import LlamaStackDistribution, create_llama_stack_distribution
20+
from ocp_resources.llama_stack_distribution import LlamaStackDistribution
21+
from utilities.rag_utils import create_llama_stack_distribution
2122

2223
LOGGER = get_logger(name=__name__)
2324

@@ -38,14 +39,12 @@ def llama_stack_server() -> Dict[str, Any]:
3839
{"name": "VLLM_TLS_VERIFY", "value": "false"},
3940
{"name": "VLLM_API_TOKEN", "value": rag_vllm_token},
4041
{"name": "VLLM_URL", "value": rag_vllm_url},
41-
{"name": "MILVUS_DB_PATH", "value": "~/.llama/milvus.db"},
4242
{"name": "FMS_ORCHESTRATOR_URL", "value": "http://localhost"},
4343
],
4444
"name": "llama-stack",
4545
"port": 8321,
4646
},
47-
"distribution": {"image": "quay.io/opendatahub/llama-stack:odh"},
48-
"storage": {"size": "5Gi"},
47+
"distribution": {"name": "rh-dev"},
4948
}
5049

5150

@@ -99,15 +98,7 @@ def llama_stack_distribution_deployment(
9998
name="rag-llama-stack-distribution",
10099
)
101100

102-
timeout = Timeout.TIMEOUT_15_SEC
103-
sampler = TimeoutSampler(
104-
wait_timeout=timeout, sleep=1, func=lambda deployment: deployment.exists is not None, deployment=deployment
105-
)
106-
for item in sampler:
107-
if item:
108-
break # Break after first successful iteration
109-
110-
assert deployment.exists, f"llama stack distribution deployment doesn't exist within {timeout} seconds"
101+
deployment.wait(timeout=Timeout.TIMEOUT_2MIN)
111102
yield deployment
112103

113104

utilities/rag_utils.py

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from contextlib import contextmanager
2-
from ocp_resources.resource import NamespacedResource
2+
from ocp_resources.llama_stack_distribution import LlamaStackDistribution
33
from kubernetes.dynamic import DynamicClient
44
from typing import Any, Dict, Generator, List, TypedDict, cast
55
from llama_stack_client import Agent, AgentEventLogger
@@ -8,29 +8,6 @@
88
LOGGER = get_logger(name=__name__)
99

1010

11-
class LlamaStackDistribution(NamespacedResource):
12-
api_group: str = "llamastack.io"
13-
14-
def __init__(self, replicas: int, server: Dict[str, Any], **kwargs: Any):
15-
"""
16-
Args:
17-
kwargs: Keyword arguments to pass to the LlamaStackDistribution constructor
18-
"""
19-
super().__init__(
20-
**kwargs,
21-
)
22-
self.replicas = replicas
23-
self.server = server
24-
25-
def to_dict(self) -> None:
26-
super().to_dict()
27-
if not self.kind_dict and not self.yaml_file:
28-
self.res["spec"] = {}
29-
_spec = self.res["spec"]
30-
_spec["replicas"] = self.replicas
31-
_spec["server"] = self.server
32-
33-
3411
@contextmanager
3512
def create_llama_stack_distribution(
3613
client: DynamicClient,

0 commit comments

Comments
 (0)