Skip to content

Commit e2f2fe9

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent d4549f8 commit e2f2fe9

File tree

3 files changed

+25
-29
lines changed

3 files changed

+25
-29
lines changed

tests/model_explainability/nemo_guardrails/conftest.py

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,14 @@
1313
from ocp_resources.secret import Secret
1414

1515
from tests.model_explainability.nemo_guardrails.constants import PresidioEntity
16-
from utilities.constants import LLMdInferenceSimConfig
1716
from tests.model_explainability.nemo_guardrails.utils import (
1817
create_llm_judge_config,
1918
create_presidio_config,
2019
)
2120
from utilities.certificates_utils import create_ca_bundle_file
21+
from utilities.constants import LLMdInferenceSimConfig
2222
from utilities.nemo_guardrails_resource import NemoGuardrails
2323

24-
2524
# ===========================
2625
# Secret Fixtures
2726
# ===========================
@@ -242,15 +241,12 @@ def nemo_guardrails_presidio(
242241
}
243242
],
244243
replicas=1,
245-
env=[{
246-
"name": "OPENAI_API_KEY",
247-
"valueFrom": {
248-
"secretKeyRef": {
249-
"name": nemo_api_token_secret.name,
250-
"key": "token"
251-
}
252-
},
253-
}],
244+
env=[
245+
{
246+
"name": "OPENAI_API_KEY",
247+
"valueFrom": {"secretKeyRef": {"name": nemo_api_token_secret.name, "key": "token"}},
248+
}
249+
],
254250
) as nemo_cr:
255251
# Wait for the deployment to be ready
256252
deployment = Deployment(
@@ -289,10 +285,12 @@ def nemo_guardrails_multi_config(
289285
},
290286
],
291287
replicas=1,
292-
env=[{
293-
"name": "OPENAI_API_KEY",
294-
"valueFrom": {"secretKeyRef": {"name": nemo_api_token_secret.name, "key": "token"}},
295-
}],
288+
env=[
289+
{
290+
"name": "OPENAI_API_KEY",
291+
"valueFrom": {"secretKeyRef": {"name": nemo_api_token_secret.name, "key": "token"}},
292+
}
293+
],
296294
) as nemo_cr:
297295
# Wait for the deployment to be ready
298296
deployment = Deployment(
@@ -325,10 +323,12 @@ def nemo_guardrails_second_server(
325323
}
326324
],
327325
replicas=1,
328-
env=[{
329-
"name": "OPENAI_API_KEY",
330-
"valueFrom": {"secretKeyRef": {"name": nemo_api_token_secret.name, "key": "token"}},
331-
}],
326+
env=[
327+
{
328+
"name": "OPENAI_API_KEY",
329+
"valueFrom": {"secretKeyRef": {"name": nemo_api_token_secret.name, "key": "token"}},
330+
}
331+
],
332332
) as nemo_cr:
333333
# Wait for the deployment to be ready
334334
deployment = Deployment(
@@ -435,7 +435,6 @@ def nemo_guardrails_llm_judge_healthcheck(
435435
Note: The deployment readiness is already verified in the nemo_guardrails_llm_judge fixture
436436
via deployment.wait_for_replicas(). This fixture just ensures dependencies are created.
437437
"""
438-
pass
439438

440439

441440
@pytest.fixture(scope="class")
@@ -449,7 +448,6 @@ def nemo_guardrails_presidio_healthcheck(
449448
Note: The deployment readiness is already verified in the nemo_guardrails_presidio fixture
450449
via deployment.wait_for_replicas(). This fixture just ensures dependencies are created.
451450
"""
452-
pass
453451

454452

455453
@pytest.fixture(scope="class")
@@ -463,7 +461,6 @@ def nemo_guardrails_multi_config_healthcheck(
463461
Note: The deployment readiness is already verified in the nemo_guardrails_multi_config fixture
464462
via deployment.wait_for_replicas(). This fixture just ensures dependencies are created.
465463
"""
466-
pass
467464

468465

469466
@pytest.fixture(scope="class")
@@ -477,4 +474,3 @@ def nemo_guardrails_second_server_healthcheck(
477474
Note: The deployment readiness is already verified in the nemo_guardrails_second_server fixture
478475
via deployment.wait_for_replicas(). This fixture just ensures dependencies are created.
479476
"""
480-
pass

tests/model_explainability/nemo_guardrails/test_nemo_guardrails.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
CHAT_ENDPOINT,
1212
CHECK_ENDPOINT,
1313
CLEAN_PROMPT,
14-
PII_PROMPT,
1514
MODEL_NAME,
15+
PII_PROMPT,
1616
SAFE_PROMPTS,
1717
)
1818
from tests.model_explainability.nemo_guardrails.utils import (
@@ -345,7 +345,7 @@ def test_nemo_multi_config(
345345
ca_bundle_file=openshift_ca_bundle_file,
346346
message=SAFE_PROMPTS[0],
347347
model=MODEL_NAME,
348-
configuration="config-a"
348+
configuration="config-a",
349349
)
350350

351351
assert response.status_code == 200, f"Expected 200, got {response.status_code}"
@@ -355,7 +355,7 @@ def test_nemo_multi_config(
355355
if endpoint == CHAT_ENDPOINT:
356356
assert "choices" in response_json, "Chat endpoint should contain choices"
357357
assert "guardrails" in response_json, "Response should contain guardrails metadata"
358-
assert response_json["guardrails"]['config_id'] == "config-a", "Should use config-a"
358+
assert response_json["guardrails"]["config_id"] == "config-a", "Should use config-a"
359359
elif endpoint == CHECK_ENDPOINT:
360360
assert "status" in response_json, "Check endpoint should contain status"
361361
# For checks endpoint, config selection is validated through the request params
@@ -367,7 +367,7 @@ def test_nemo_multi_config(
367367
ca_bundle_file=openshift_ca_bundle_file,
368368
message=PII_PROMPT,
369369
model=MODEL_NAME,
370-
configuration="config-b"
370+
configuration="config-b",
371371
)
372372

373373
assert response.status_code == 200, f"Expected 200, got {response.status_code}"
@@ -377,12 +377,11 @@ def test_nemo_multi_config(
377377
if endpoint == CHAT_ENDPOINT:
378378
assert "choices" in response_json, "Chat endpoint should contain choices"
379379
assert "guardrails" in response_json, "Response should contain guardrails metadata"
380-
assert response_json["guardrails"]['config_id'] == "config-b", "Should use config-b"
380+
assert response_json["guardrails"]["config_id"] == "config-b", "Should use config-b"
381381
elif endpoint == CHECK_ENDPOINT:
382382
assert "status" in response_json, "Check endpoint should contain status"
383383
# For checks endpoint, config selection is validated through the request params
384384

385-
386385
def test_nemo_multi_config_mount_paths(
387386
self,
388387
admin_client: DynamicClient,

tests/model_explainability/nemo_guardrails/utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ def create_chat_completion_request(message: str, model: str, configuration: str
198198

199199
return payload
200200

201+
201202
def send_request(
202203
url: str,
203204
token: str | None,

0 commit comments

Comments
 (0)