Skip to content

Commit 8d2c467

Browse files
rhods-ci-botsheltoncyriladolfo-ab
authored
[AI Explainability] TrustyAI DSC based LMEval configuration (#672) (#673)
* refactor: replace TrustyAI ConfigMap patching with DataScienceCluster config * Apply suggestion from @adolfo-ab * refactor: remove utils file and fn * refactor: remove unused file and code --------- Co-authored-by: Shelton Cyril <sheltoncyril@gmail.com> Co-authored-by: Adolfo Aguirrezabal <aaguirre@redhat.com>
1 parent bfdee7e commit 8d2c467

3 files changed

Lines changed: 29 additions & 32 deletions

File tree

tests/fixtures/trustyai.py

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import pytest
22
from kubernetes.dynamic import DynamicClient
3+
from ocp_resources.data_science_cluster import DataScienceCluster
34
from ocp_resources.deployment import Deployment
45

5-
from typing import Generator, Any
6+
from typing import Generator
67

7-
from ocp_resources.config_map import ConfigMap
88
from ocp_resources.resource import ResourceEditor
99
from pytest_testconfig import py_config
1010

11-
from utilities.constants import Annotations, TRUSTYAI_SERVICE_NAME
11+
from utilities.constants import TRUSTYAI_SERVICE_NAME
12+
from utilities.infra import get_data_science_cluster
1213

1314

1415
@pytest.fixture(scope="class")
@@ -21,36 +22,32 @@ def trustyai_operator_deployment(admin_client: DynamicClient) -> Deployment:
2122
)
2223

2324

24-
@pytest.fixture(scope="function")
25-
def patched_trustyai_configmap_allow_online(
26-
admin_client: DynamicClient, trustyai_operator_deployment: Deployment
27-
) -> Generator[ConfigMap, Any, Any]:
28-
"""
29-
Patches the TrustyAI Operator ConfigMap in order to set allowOnline and allowCodeExecution to true.
30-
These options are needed to run some LMEval tasks, which rely on having access to the internet
31-
and running arbitrary code. The deployment needs to be restarted in order for these changes to be applied.
32-
"""
33-
trustyai_service_operator: str = "trustyai-service-operator"
34-
35-
configmap: ConfigMap = ConfigMap(
36-
client=admin_client,
37-
name=f"{trustyai_service_operator}-config",
38-
namespace=py_config["applications_namespace"],
39-
ensure_exists=True,
40-
)
25+
@pytest.fixture(scope="class")
26+
def patched_dsc_lmeval_allow_all(
27+
admin_client, trustyai_operator_deployment: Deployment
28+
) -> Generator[DataScienceCluster, None, None]:
29+
"""Enable LMEval PermitOnline and PermitCodeExecution flags in the Datascience cluster."""
30+
dsc = get_data_science_cluster(client=admin_client)
4131
with ResourceEditor(
4232
patches={
43-
configmap: {
44-
"metadata": {"annotations": {Annotations.OpenDataHubIo.MANAGED: "false"}},
45-
"data": {
46-
"lmes-allow-online": "true",
47-
"lmes-allow-code-execution": "true",
48-
},
33+
dsc: {
34+
"spec": {
35+
"components": {
36+
"trustyai": {
37+
"eval": {
38+
"lmeval": {
39+
"permitCodeExecution": "allow",
40+
"permitOnline": "allow",
41+
}
42+
}
43+
}
44+
}
45+
}
4946
}
5047
}
5148
):
5249
num_replicas: int = trustyai_operator_deployment.replicas
5350
trustyai_operator_deployment.scale_replicas(replica_count=0)
5451
trustyai_operator_deployment.scale_replicas(replica_count=num_replicas)
5552
trustyai_operator_deployment.wait_for_replicas()
56-
yield configmap
53+
yield dsc

tests/llama_stack/eval/test_lmeval_provider.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def test_lmeval_register_benchmark(self, minio_pod, minio_data_connection, llama
5252
assert benchmarks[0].provider_id == LlamaStackProviders.Eval.TRUSTYAI_LMEVAL
5353

5454
def test_llamastack_run_eval(
55-
self, minio_pod, minio_data_connection, patched_trustyai_configmap_allow_online, llama_stack_client
55+
self, minio_pod, minio_data_connection, patched_dsc_lmeval_allow_all, llama_stack_client
5656
):
5757
job = llama_stack_client.eval.run_eval(
5858
benchmark_id=TRUSTYAI_LMEVAL_ARCEASY,

tests/model_explainability/lm_eval/conftest.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import pytest
44
from kubernetes.dynamic import DynamicClient
5-
from ocp_resources.config_map import ConfigMap
5+
from ocp_resources.data_science_cluster import DataScienceCluster
66
from ocp_resources.deployment import Deployment
77
from ocp_resources.lm_eval_job import LMEvalJob
88
from ocp_resources.namespace import Namespace
@@ -27,7 +27,7 @@ def lmevaljob_hf(
2727
request: FixtureRequest,
2828
admin_client: DynamicClient,
2929
model_namespace: Namespace,
30-
patched_trustyai_configmap_allow_online: ConfigMap,
30+
patched_dsc_lmeval_allow_all: DataScienceCluster,
3131
lmeval_hf_access_token: Secret,
3232
) -> Generator[LMEvalJob, None, None]:
3333
with LMEvalJob(
@@ -74,7 +74,7 @@ def lmevaljob_local_offline(
7474
request: FixtureRequest,
7575
admin_client: DynamicClient,
7676
model_namespace: Namespace,
77-
patched_trustyai_configmap_allow_online: ConfigMap,
77+
patched_dsc_lmeval_allow_all: DataScienceCluster,
7878
lmeval_data_downloader_pod: Pod,
7979
) -> Generator[LMEvalJob, Any, Any]:
8080
with LMEvalJob(
@@ -104,7 +104,7 @@ def lmevaljob_local_offline(
104104
def lmevaljob_vllm_emulator(
105105
admin_client: DynamicClient,
106106
model_namespace: Namespace,
107-
patched_trustyai_configmap_allow_online: ConfigMap,
107+
patched_dsc_lmeval_allow_all: DataScienceCluster,
108108
vllm_emulator_deployment: Deployment,
109109
vllm_emulator_service: Service,
110110
vllm_emulator_route: Route,

0 commit comments

Comments
 (0)