Skip to content

Commit 270c710

Browse files
authored
feat: replace Qwen2.5 image used in guardrails tests (opendatahub-io#352)
* feat: replace Qwen2.5 image used in guardrails tests * fix: vllm_runtime type hint
1 parent 77bd770 commit 270c710

3 files changed

Lines changed: 18 additions & 92 deletions

File tree

tests/model_explainability/guardrails/conftest.py

Lines changed: 6 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from ocp_resources.guardrails_orchestrator import GuardrailsOrchestrator
99
from ocp_resources.inference_service import InferenceService
1010
from ocp_resources.namespace import Namespace
11-
from ocp_resources.persistent_volume_claim import PersistentVolumeClaim
1211
from ocp_resources.pod import Pod
1312
from ocp_resources.route import Route
1413
from ocp_resources.secret import Secret
@@ -18,8 +17,6 @@
1817
from utilities.constants import (
1918
KServeDeploymentType,
2019
Labels,
21-
MinIo,
22-
Timeout,
2320
Ports,
2421
RuntimeTemplates,
2522
)
@@ -78,9 +75,11 @@ def guardrails_orchestrator_pod(
7875

7976

8077
@pytest.fixture(scope="class")
81-
def qwen_llm_model(
78+
def qwen_isvc(
8279
admin_client: DynamicClient,
8380
model_namespace: Namespace,
81+
minio_pod: Pod,
82+
minio_service: Service,
8483
minio_data_connection: Secret,
8584
vllm_runtime: ServingRuntime,
8685
) -> Generator[InferenceService, Any, Any]:
@@ -107,7 +106,7 @@ def qwen_llm_model(
107106
def vllm_runtime(
108107
admin_client: DynamicClient,
109108
model_namespace: Namespace,
110-
minio_llm_deployment: Deployment,
109+
minio_pod: Pod,
111110
minio_service: Service,
112111
minio_data_connection: Secret,
113112
) -> Generator[ServingRuntime, Any, Any]:
@@ -138,7 +137,7 @@ def vllm_runtime(
138137
def orchestrator_configmap(
139138
admin_client: DynamicClient,
140139
model_namespace: Namespace,
141-
qwen_llm_model: InferenceService,
140+
qwen_isvc: InferenceService,
142141
) -> Generator[ConfigMap, Any, Any]:
143142
with ConfigMap(
144143
client=admin_client,
@@ -148,7 +147,7 @@ def orchestrator_configmap(
148147
"config.yaml": yaml.dump({
149148
"chat_generation": {
150149
"service": {
151-
"hostname": f"{qwen_llm_model.name}-predictor.{model_namespace.name}.svc.cluster.local",
150+
"hostname": f"{qwen_isvc.name}-predictor.{model_namespace.name}.svc.cluster.local",
152151
"port": GUARDRAILS_ORCHESTRATOR_PORT,
153152
}
154153
},
@@ -205,82 +204,3 @@ def guardrails_gateway_config(
205204
},
206205
) as cm:
207206
yield cm
208-
209-
210-
@pytest.fixture(scope="class")
211-
def minio_llm_deployment(
212-
admin_client: DynamicClient,
213-
minio_namespace: Namespace,
214-
pvc_minio_namespace: PersistentVolumeClaim,
215-
) -> Generator[Deployment, Any, Any]:
216-
with Deployment(
217-
client=admin_client,
218-
name="llm-container-deployment",
219-
namespace=minio_namespace.name,
220-
replicas=1,
221-
selector={"matchLabels": {Labels.Openshift.APP: MinIo.Metadata.NAME}},
222-
template={
223-
"metadata": {
224-
"labels": {
225-
Labels.Openshift.APP: MinIo.Metadata.NAME,
226-
"maistra.io/expose-route": "true",
227-
},
228-
"name": MinIo.Metadata.NAME,
229-
},
230-
"spec": {
231-
"volumes": [
232-
{
233-
"name": "model-volume",
234-
"persistentVolumeClaim": {"claimName": pvc_minio_namespace.name},
235-
}
236-
],
237-
"initContainers": [
238-
{
239-
"name": "download-model",
240-
"image": "quay.io/trustyai_testing/llm-downloader-bootstrap"
241-
"@sha256:d3211cc581fe69ca9a1cb75f84e5d08cacd1854cb2d63591439910323b0cbb57",
242-
"securityContext": {"fsGroup": 1001},
243-
"command": [
244-
"bash",
245-
"-c",
246-
'model="Qwen/Qwen2.5-0.5B-Instruct"'
247-
'\necho "starting download"'
248-
"\n/tmp/venv/bin/huggingface-cli download $model "
249-
"--local-dir /mnt/models/llms/$(basename $model)"
250-
'\necho "Done!"',
251-
],
252-
"resources": {"limits": {"memory": "5Gi", "cpu": "2"}},
253-
"volumeMounts": [{"mountPath": "/mnt/models/", "name": "model-volume"}],
254-
}
255-
],
256-
"containers": [
257-
{
258-
"args": ["server", "/models"],
259-
"env": [
260-
{
261-
"name": MinIo.Credentials.ACCESS_KEY_NAME,
262-
"value": MinIo.Credentials.ACCESS_KEY_VALUE,
263-
},
264-
{
265-
"name": MinIo.Credentials.SECRET_KEY_NAME,
266-
"value": MinIo.Credentials.SECRET_KEY_VALUE,
267-
},
268-
],
269-
"image": "quay.io/trustyai/modelmesh-minio-examples"
270-
"@sha256:65cb22335574b89af15d7409f62feffcc52cc0e870e9419d63586f37706321a5",
271-
"name": MinIo.Metadata.NAME,
272-
"securityContext": {
273-
"allowPrivilegeEscalation": False,
274-
"capabilities": {"drop": ["ALL"]},
275-
"seccompProfile": {"type": "RuntimeDefault"},
276-
},
277-
"volumeMounts": [{"mountPath": "/models/", "name": "model-volume"}],
278-
}
279-
],
280-
},
281-
},
282-
label={Labels.Openshift.APP: MinIo.Metadata.NAME},
283-
wait_for_resource=True,
284-
) as deployment:
285-
deployment.wait_for_replicas(timeout=Timeout.TIMEOUT_10MIN)
286-
yield deployment

tests/model_explainability/guardrails/test_guardrails.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,24 @@
55
from timeout_sampler import retry
66

77
from tests.model_explainability.utils import validate_tai_component_images
8-
from utilities.constants import Timeout
8+
from utilities.constants import Timeout, MinIo
99

1010

1111
@pytest.mark.parametrize(
12-
"model_namespace, minio_data_connection",
12+
"model_namespace, minio_pod, minio_data_connection",
1313
[
1414
pytest.param(
1515
{"name": "test-guardrails"},
16+
MinIo.PodConfig.QWEN_MINIO_CONFIG,
1617
{"bucket": "llms"},
1718
)
1819
],
1920
indirect=True,
2021
)
2122
@pytest.mark.rawdeployment
22-
class TestGuardrails:
23-
def test_guardrails_health_endpoint(self, admin_client, qwen_llm_model, guardrails_orchestrator_health_route):
23+
@pytest.mark.smoke
24+
class TestGuardrailsOrchestrator:
25+
def test_guardrails_health_endpoint(self, admin_client, qwen_isvc, guardrails_orchestrator_health_route):
2426
# It takes a bit for the endpoint to come online, so we retry for a brief period of time
2527
@retry(wait_timeout=Timeout.TIMEOUT_1MIN, sleep=1)
2628
def check_health_endpoint():
@@ -32,7 +34,7 @@ def check_health_endpoint():
3234
response = check_health_endpoint()
3335
assert "fms-guardrails-orchestr8" in response.text
3436

35-
def test_guardrails_info_endpoint(self, admin_client, qwen_llm_model, guardrails_orchestrator_health_route):
37+
def test_guardrails_info_endpoint(self, admin_client, qwen_isvc, guardrails_orchestrator_health_route):
3638
response = requests.get(url=f"https://{guardrails_orchestrator_health_route.host}/info", verify=False)
3739
assert response.status_code == http.HTTPStatus.OK
3840

@@ -41,7 +43,6 @@ def test_guardrails_info_endpoint(self, admin_client, qwen_llm_model, guardrails
4143
assert response_data["services"]["chat_generation"]["status"] == healthy_status
4244
assert response_data["services"]["regex"]["status"] == healthy_status
4345

44-
@pytest.mark.smoke
4546
def test_validate_guardrails_orchestrator_images(self, guardrails_orchestrator_pod, trustyai_operator_configmap):
4647
"""Test to verify Guardrails pod images.
4748
Checks if the image tag from the ConfigMap is used within the Pod and if it's pinned using a sha256 digest.

utilities/constants.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,11 @@ class PodConfig:
260260
**MINIO_BASE_CONFIG,
261261
}
262262

263+
QWEN_MINIO_CONFIG: dict[str, Any] = {
264+
"image": "quay.io/trustyai_testing/qwen-minio@sha256:d1e244e24d2e40fb2557e85b4587d56084253c040fc4e64421f3ccc09ec8e5c3", # noqa: E501
265+
**MINIO_BASE_CONFIG,
266+
}
267+
263268
KSERVE_MINIO_CONFIG: dict[str, Any] = {
264269
"image": KSERVE_MINIO_IMAGE,
265270
**MINIO_BASE_CONFIG,

0 commit comments

Comments
 (0)