Skip to content

Commit b0ac8bf

Browse files
committed
fix: resolve pre-commit issues after rebase
- Remove duplicate test_lmeval_huggingface_model_tier2 function - Fix bare Exception catch in wait_for_service_account - Auto-format fixes from ruff Signed-off-by: Shelton Cyril <sheltoncyril@gmail.com>
1 parent 3f93be9 commit b0ac8bf

File tree

10 files changed

+59
-79
lines changed

10 files changed

+59
-79
lines changed

tests/fixtures/inference.py

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -349,23 +349,17 @@ def patched_dsc_garak_kfp(admin_client) -> Generator[DataScienceCluster]:
349349

350350
dsc = get_data_science_cluster(client=admin_client)
351351
with ResourceEditor(
352-
patches={
353-
dsc: {
354-
"spec": {
355-
"components": {
356-
"kserve": {
357-
"rawDeploymentServiceConfig": "Headed"
358-
},
359-
"aipipelines": {
360-
"managementState": "Managed"
361-
},
362-
"mlflowoperator": {
363-
"managementState": "Managed"
364-
}
365-
}
352+
patches={
353+
dsc: {
354+
"spec": {
355+
"components": {
356+
"kserve": {"rawDeploymentServiceConfig": "Headed"},
357+
"aipipelines": {"managementState": "Managed"},
358+
"mlflowoperator": {"managementState": "Managed"},
366359
}
367360
}
368361
}
369-
):
370-
wait_for_dsc_status_ready(dsc_resource=dsc)
371-
yield dsc
362+
}
363+
):
364+
wait_for_dsc_status_ready(dsc_resource=dsc)
365+
yield dsc

tests/llama_stack/safety/test_trustyai_fms_provider.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
LOGGER = structlog.get_logger(name=__name__)
99
SECURE_SHIELD_ID: str = "secure_shield"
1010

11+
1112
@pytest.mark.tier1
1213
@pytest.mark.parametrize(
1314
"model_namespace, minio_pod, minio_data_connection, "

tests/model_explainability/evalhub/conftest.py

Lines changed: 37 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,11 @@
88
from ocp_resources.deployment import Deployment
99
from ocp_resources.inference_service import InferenceService
1010
from ocp_resources.namespace import Namespace
11-
from ocp_resources.project_project_openshift_io import Project
1211
from ocp_resources.role import Role
1312
from ocp_resources.role_binding import RoleBinding
1413
from ocp_resources.route import Route
1514
from ocp_resources.secret import Secret
1615
from ocp_resources.service_account import ServiceAccount
17-
from ocp_resources.serving_runtime import ServingRuntime
1816
from pytest_testconfig import config as py_config
1917

2018
from tests.model_explainability.evalhub.constants import (
@@ -203,9 +201,7 @@ def tenant_namespace(
203201

204202
@pytest.fixture(scope="class")
205203
def evalhub_job_service_account(
206-
admin_client: DynamicClient,
207-
model_namespace: Namespace,
208-
tenant_namespace: Namespace
204+
admin_client: DynamicClient, model_namespace: Namespace, tenant_namespace: Namespace
209205
) -> ServiceAccount:
210206
"""Wait for the auto-created EvalHub job ServiceAccount in the tenant namespace."""
211207
sa_name = f"{EVALHUB_JOB_SA_PREFIX}{model_namespace.name}{EVALHUB_JOB_SA_SUFFIX}"
@@ -363,10 +359,12 @@ def dspa_secret_patch(
363359
"AWS_DEFAULT_REGION": "us-east-1",
364360
}
365361

366-
secret.update(resource_dict={
367-
"metadata": {"name": secret.name, "namespace": tenant_namespace.name},
368-
"stringData": secret_data,
369-
})
362+
secret.update(
363+
resource_dict={
364+
"metadata": {"name": secret.name, "namespace": tenant_namespace.name},
365+
"stringData": secret_data,
366+
}
367+
)
370368
LOGGER.info(f"Patched DSPA S3 secret with additional fields in {tenant_namespace.name}")
371369
return secret
372370

@@ -379,20 +377,21 @@ def dsp_access_for_job_sa(
379377
tenant_dspa: DataSciencePipelinesApplication,
380378
) -> Generator[tuple[Role, RoleBinding, RoleBinding], Any, Any]:
381379
"""Grant the EvalHub job ServiceAccount access to the DSP API and pipeline management."""
382-
with Role(
383-
client=admin_client,
384-
name="evalhub-jobs-dspa-api",
385-
namespace=tenant_namespace.name,
386-
rules=[
387-
{
388-
"apiGroups": ["datasciencepipelinesapplications.opendatahub.io"],
389-
"resources": ["datasciencepipelinesapplications/api"],
390-
"verbs": ["get", "create"],
391-
},
392-
],
393-
wait_for_resource=True,
394-
) as role:
395-
with RoleBinding(
380+
with (
381+
Role(
382+
client=admin_client,
383+
name="evalhub-jobs-dspa-api",
384+
namespace=tenant_namespace.name,
385+
rules=[
386+
{
387+
"apiGroups": ["datasciencepipelinesapplications.opendatahub.io"],
388+
"resources": ["datasciencepipelinesapplications/api"],
389+
"verbs": ["get", "create"],
390+
},
391+
],
392+
wait_for_resource=True,
393+
) as role,
394+
RoleBinding(
396395
client=admin_client,
397396
name="evalhub-jobs-dspa-api",
398397
namespace=tenant_namespace.name,
@@ -402,20 +401,20 @@ def dsp_access_for_job_sa(
402401
subjects_name=evalhub_job_service_account.name,
403402
subjects_namespace=tenant_namespace.name,
404403
wait_for_resource=True,
405-
) as api_binding:
406-
with RoleBinding(
407-
client=admin_client,
408-
name="evalhub-jobs-pipeline-management",
409-
namespace=tenant_namespace.name,
410-
role_ref_kind="Role",
411-
role_ref_name="ds-pipeline-dspa",
412-
subjects_kind="ServiceAccount",
413-
subjects_name=evalhub_job_service_account.name,
414-
subjects_namespace=tenant_namespace.name,
415-
wait_for_resource=True,
416-
) as pipeline_binding:
417-
yield role, api_binding, pipeline_binding
418-
404+
) as api_binding,
405+
RoleBinding(
406+
client=admin_client,
407+
name="evalhub-jobs-pipeline-management",
408+
namespace=tenant_namespace.name,
409+
role_ref_kind="Role",
410+
role_ref_name="ds-pipeline-dspa",
411+
subjects_kind="ServiceAccount",
412+
subjects_name=evalhub_job_service_account.name,
413+
subjects_namespace=tenant_namespace.name,
414+
wait_for_resource=True,
415+
) as pipeline_binding,
416+
):
417+
yield role, api_binding, pipeline_binding
419418

420419

421420
# ---------------------------------------------------------------------------
@@ -426,7 +425,4 @@ def dsp_access_for_job_sa(
426425
@pytest.fixture(scope="class")
427426
def garak_sim_isvc_url(llm_d_inference_sim_isvc: InferenceService) -> str:
428427
"""Get the internal service URL for the LLM-d inference simulator."""
429-
return (
430-
f"http://{llm_d_inference_sim_isvc.name}-predictor.{llm_d_inference_sim_isvc.namespace}"
431-
f".svc.cluster.local/v1"
432-
)
428+
return f"http://{llm_d_inference_sim_isvc.name}-predictor.{llm_d_inference_sim_isvc.namespace}.svc.cluster.local/v1"

tests/model_explainability/evalhub/constants.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,3 @@
2929
# Job service account naming
3030
EVALHUB_JOB_SA_PREFIX: str = "evalhub-"
3131
EVALHUB_JOB_SA_SUFFIX: str = "-job"
32-

tests/model_explainability/evalhub/test_garak.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
GARAK_BENCHMARK_ID,
88
GARAK_PROVIDER_ID,
99
)
10-
from utilities.constants import LLMdInferenceSimConfig
1110
from tests.model_explainability.evalhub.utils import (
1211
submit_garak_job,
1312
validate_evalhub_health,
1413
validate_evalhub_providers,
1514
wait_for_job_completion,
1615
)
16+
from utilities.constants import LLMdInferenceSimConfig
1717

1818

1919
@pytest.mark.parametrize(

tests/model_explainability/evalhub/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ def _sa_exists() -> ServiceAccount | None:
214214
sa = ServiceAccount(client=admin_client, name=sa_name, namespace=namespace)
215215
if sa.exists:
216216
return sa
217-
except Exception:
217+
except ValueError, AttributeError:
218218
pass
219219
return None
220220

tests/model_explainability/guardrails/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ def minio_deployment_otel(admin_client, model_namespace, minio_pvc_otel):
457457
{
458458
"name": "minio",
459459
"image": "quay.io/minio/minio"
460-
"@sha256:14cea493d9a34af32f524e538b8346cf79f3321eff8e708c1e2960462bd8936e",
460+
"@sha256:14cea493d9a34af32f524e538b8346cf79f3321eff8e708c1e2960462bd8936e",
461461
"command": ["/bin/sh", "-c", "mkdir -p /storage/tempo && minio server /storage"],
462462
"env": [
463463
{"name": "MINIO_ACCESS_KEY", "value": TEMPO},

tests/model_explainability/guardrails/test_guardrails.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737

3838
LOGGER = structlog.get_logger(name=__name__)
3939

40+
4041
@pytest.mark.smoke
4142
@pytest.mark.parametrize(
4243
"model_namespace, orchestrator_config, guardrails_orchestrator",
@@ -68,6 +69,7 @@ def test_validate_guardrails_orchestrator_images(
6869
"""
6970
validate_tai_component_images(pod=guardrails_orchestrator_pod, tai_operator_configmap=trustyai_operator_configmap)
7071

72+
7173
@pytest.mark.smoke
7274
@pytest.mark.parametrize(
7375
"model_namespace, orchestrator_config, guardrails_gateway_config, guardrails_orchestrator",
@@ -209,6 +211,7 @@ def test_guardrails_builtin_detectors_negative_detection(
209211
model=LLMdInferenceSimConfig.model_name,
210212
)
211213

214+
212215
@pytest.mark.smoke
213216
@pytest.mark.parametrize(
214217
"model_namespace, orchestrator_config, guardrails_gateway_config,guardrails_orchestrator",

tests/model_explainability/lm_eval/test_lm_eval.py

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -54,23 +54,6 @@ def test_lmeval_huggingface_model(admin_client, model_namespace, lmevaljob_hf_po
5454
On each test we run a different evaluation task, limiting it to 0.5% of the questions on each eval."""
5555
validate_lmeval_job_pod_and_logs(lmevaljob_pod=lmevaljob_hf_pod)
5656

57-
@pytest.mark.skip_on_disconnected
58-
@pytest.mark.tier2
59-
@pytest.mark.parametrize(
60-
"model_namespace, lmevaljob_hf",
61-
[
62-
63-
pytest.param(
64-
{"name": "test-lmeval-hf-tier2"},
65-
{"task_list": {"taskNames": TIER2_LMEVAL_TASKS}},
66-
),
67-
],
68-
indirect=True,
69-
)
70-
def test_lmeval_huggingface_model_tier2(admin_client, model_namespace, lmevaljob_hf_pod):
71-
"""Tests that verify running common evaluations (and a custom one) on a model pulled directly from HuggingFace.
72-
On each test we run a different evaluation task, limiting it to 0.5% of the questions on each eval."""
73-
validate_lmeval_job_pod_and_logs(lmevaljob_pod=lmevaljob_hf_pod)
7457

7558
@pytest.mark.skip_on_disconnected
7659
@pytest.mark.tier2
@@ -171,6 +154,7 @@ def test_verify_lmeval_pod_images(lmevaljob_s3_offline_pod, trustyai_operator_co
171154
pod=lmevaljob_s3_offline_pod, tai_operator_configmap=trustyai_operator_configmap, include_init_containers=True
172155
)
173156

157+
174158
@pytest.mark.tier1
175159
@pytest.mark.parametrize(
176160
"model_namespace, oci_registry_pod_with_minio, lmeval_data_downloader_pod, lmevaljob_local_offline_oci",

tests/model_explainability/trustyai_service/service/test_trustyai_service.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
)
2222
from utilities.constants import MinIo
2323

24+
2425
@pytest.mark.tier1
2526
@pytest.mark.parametrize(
2627
"model_namespace",
@@ -44,6 +45,7 @@ def test_trustyai_service_with_invalid_db_cert(
4445
label_selector=f"app.kubernetes.io/instance={trustyai_service_with_invalid_db_cert.name}",
4546
)
4647

48+
4749
@pytest.mark.smoke
4850
@pytest.mark.parametrize(
4951
"model_namespace, trustyai_service",
@@ -70,6 +72,7 @@ def test_validate_trustyai_service_image(
7072
trustyai_operator_configmap=trustyai_operator_configmap,
7173
)
7274

75+
7376
@pytest.mark.tier1
7477
@pytest.mark.parametrize(
7578
"model_namespace, minio_pod, minio_data_connection, trustyai_service",

0 commit comments

Comments
 (0)