Skip to content

Commit a97259b

Browse files
feat: Add systematic testing of LMEval tasks (#380)
* feat: Add systematic testing of LMEval tasks * [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 6b9696a commit a97259b

File tree

6 files changed

+11315
-13
lines changed

6 files changed

+11315
-13
lines changed

conftest.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def pytest_addoption(parser: Parser) -> None:
4848
upgrade_group = parser.getgroup(name="Upgrade options")
4949
must_gather_group = parser.getgroup(name="MustGather")
5050
cluster_sanity_group = parser.getgroup(name="ClusterSanity")
51+
hf_group = parser.getgroup(name="Hugging Face")
5152

5253
# AWS config and credentials options
5354
aws_group.addoption(
@@ -152,6 +153,9 @@ def pytest_addoption(parser: Parser) -> None:
152153
action="store_true",
153154
)
154155

156+
# HuggingFace options
157+
hf_group.addoption("--hf-access-token", default=os.environ.get("HF_ACCESS_TOKEN"), help="HF access token")
158+
155159

156160
def pytest_cmdline_main(config: Any) -> None:
157161
config.option.basetemp = py_config["tmp_base_dir"] = f"{config.option.basetemp}-{shortuuid.uuid()}"

tests/model_explainability/lm_eval/conftest.py

Lines changed: 56 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
from typing import Generator, Any
1+
from typing import Any, Generator
22

33
import pytest
4-
from ocp_resources.route import Route
5-
from ocp_resources.secret import Secret
6-
from ocp_resources.service import Service
7-
from pytest import FixtureRequest
84
from kubernetes.dynamic import DynamicClient
95
from ocp_resources.config_map import ConfigMap
106
from ocp_resources.deployment import Deployment
@@ -13,10 +9,15 @@
139
from ocp_resources.persistent_volume_claim import PersistentVolumeClaim
1410
from ocp_resources.pod import Pod
1511
from ocp_resources.resource import ResourceEditor
12+
from ocp_resources.route import Route
13+
from ocp_resources.secret import Secret
14+
from ocp_resources.service import Service
15+
from pytest import Config, FixtureRequest
1616
from pytest_testconfig import py_config
1717

1818
from tests.model_explainability.lm_eval.utils import get_lmevaljob_pod
19-
from utilities.constants import Labels, Timeout, Annotations, Protocols, MinIo
19+
from utilities.constants import Annotations, Labels, MinIo, Protocols, Timeout
20+
from utilities.exceptions import MissingParameter
2021

2122
VLLM_EMULATOR: str = "vllm-emulator"
2223
VLLM_EMULATOR_PORT: int = 8000
@@ -29,6 +30,7 @@ def lmevaljob_hf(
2930
admin_client: DynamicClient,
3031
model_namespace: Namespace,
3132
patched_trustyai_operator_configmap_allow_online: ConfigMap,
33+
lmeval_hf_access_token: Secret,
3234
) -> Generator[LMEvalJob, None, None]:
3335
with LMEvalJob(
3436
client=admin_client,
@@ -45,6 +47,26 @@ def lmevaljob_hf(
4547
"enabled": True,
4648
},
4749
limit="0.01",
50+
pod={
51+
"container": {
52+
"resources": {
53+
"limits": {"cpu": "1", "memory": "8Gi"},
54+
"requests": {"cpu": "1", "memory": "8Gi"},
55+
},
56+
"env": [
57+
{
58+
"name": "HF_TOKEN",
59+
"valueFrom": {
60+
"secretKeyRef": {
61+
"name": "hf-secret",
62+
"key": "HF_ACCESS_TOKEN",
63+
},
64+
},
65+
},
66+
{"name": "HF_ALLOW_CODE_EVAL", "value": "1"},
67+
],
68+
},
69+
},
4870
) as job:
4971
yield job
5072

@@ -127,7 +149,10 @@ def patched_trustyai_operator_configmap_allow_online(admin_client: DynamicClient
127149
patches={
128150
configmap: {
129151
"metadata": {"annotations": {Annotations.OpenDataHubIo.MANAGED: "false"}},
130-
"data": {"lmes-allow-online": "true", "lmes-allow-code-execution": "true"},
152+
"data": {
153+
"lmes-allow-online": "true",
154+
"lmes-allow-code-execution": "true",
155+
},
131156
}
132157
}
133158
):
@@ -404,3 +429,27 @@ def lmevaljob_vllm_emulator_pod(
404429
@pytest.fixture(scope="function")
405430
def lmevaljob_s3_offline_pod(admin_client: DynamicClient, lmevaljob_s3_offline: LMEvalJob) -> Generator[Pod, Any, Any]:
406431
yield get_lmevaljob_pod(client=admin_client, lmevaljob=lmevaljob_s3_offline)
432+
433+
434+
@pytest.fixture(scope="function")
435+
def lmeval_hf_access_token(
436+
admin_client: DynamicClient,
437+
model_namespace: Namespace,
438+
pytestconfig: Config,
439+
) -> Secret:
440+
hf_access_token = pytestconfig.option.hf_access_token
441+
if not hf_access_token:
442+
raise MissingParameter(
443+
"HF access token is not set. "
444+
"Either pass with `--hf-access-token` or set `HF_ACCESS_TOKEN` environment variable"
445+
)
446+
with Secret(
447+
client=admin_client,
448+
name="hf-secret",
449+
namespace=model_namespace.name,
450+
string_data={
451+
"HF_ACCESS_TOKEN": hf_access_token,
452+
},
453+
wait_for_resource=True,
454+
) as secret:
455+
yield secret

0 commit comments

Comments
 (0)