Skip to content

Commit f60abf3

Browse files
committed
change: update uv.lock
2 parents f5cf48b + e75c8af commit f60abf3

File tree

5 files changed

+27
-10
lines changed

5 files changed

+27
-10
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ repos:
3535
- id: detect-secrets
3636

3737
- repo: https://github.com/astral-sh/ruff-pre-commit
38-
rev: v0.11.2
38+
rev: v0.11.4
3939
hooks:
4040
- id: ruff
4141
- id: ruff-format

tests/conftest.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from simple_logger.logger import get_logger
2525

2626
from utilities.data_science_cluster_utils import update_components_in_dsc
27+
from utilities.exceptions import ClusterLoginError
2728
from utilities.general import get_s3_secret_dict
2829
from utilities.infra import (
2930
create_ns,
@@ -246,33 +247,36 @@ def unprivileged_client(
246247
non_admin_user_password: tuple[str, str],
247248
) -> Generator[DynamicClient, Any, Any]:
248249
"""
249-
Provides none privileged API client. If non_admin_user_password is None, then it will yield admin_client.
250+
Provides none privileged API client. If non_admin_user_password is None, then it will raise.
250251
"""
251252
if non_admin_user_password is None:
252-
yield admin_client
253+
raise ValueError("Unprivileged user not provisioned")
253254

254255
else:
255256
current_user = run_command(command=["oc", "whoami"])[1].strip()
257+
non_admin_user_name = non_admin_user_password[0]
256258

257259
if login_with_user_password(
258260
api_address=admin_client.configuration.host,
259-
user=non_admin_user_password[0],
261+
user=non_admin_user_name,
260262
password=non_admin_user_password[1],
261263
):
262264
with open(kubconfig_filepath) as fd:
263265
kubeconfig_content = yaml.safe_load(fd)
264266

265267
unprivileged_context = kubeconfig_content["current-context"]
266268

269+
unprivileged_client = get_client(config_file=kubconfig_filepath, context=unprivileged_context)
270+
267271
# Get back to admin account
268272
login_with_user_password(
269273
api_address=admin_client.configuration.host,
270274
user=current_user.strip(),
271275
)
272-
yield get_client(config_file=kubconfig_filepath, context=unprivileged_context)
276+
yield unprivileged_client
273277

274278
else:
275-
yield admin_client
279+
raise ClusterLoginError(user=non_admin_user_name)
276280

277281

278282
@pytest.fixture(scope="session")

tests/model_explainability/trustyai_service/drift/conftest.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ def mlserver_runtime(
6363
protocol_versions=["v2"],
6464
annotations={
6565
f"{ApiGroups.OPENDATAHUB_IO}/accelerator-name": "",
66-
f"{ApiGroups.OPENDATAHUB_IO}/recommended-accelerators": [Labels.Nvidia.NVIDIA_COM_GPU],
6766
f"{ApiGroups.OPENDATAHUB_IO}/template-display-name": "KServe MLServer",
6867
"prometheus.kserve.io/path": "/metrics",
6968
"prometheus.io/port": str(Ports.REST_PORT),

utilities/exceptions.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,11 @@ class PodLogMissMatchError(Exception):
8484

8585
class ResourceMismatch(Exception):
8686
pass
87+
88+
89+
class ClusterLoginError(Exception):
90+
def __init__(self, user: str):
91+
self.user = user
92+
93+
def __str__(self) -> str:
94+
return f"Failed to log in as user {self.user}."

utilities/infra.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
from utilities.constants import ApiGroups, Labels, Timeout
4040
from utilities.constants import KServeDeploymentType
4141
from utilities.constants import Annotations
42-
from utilities.exceptions import FailedPodsError
42+
from utilities.exceptions import ClusterLoginError, FailedPodsError
4343
from timeout_sampler import TimeoutExpiredError, TimeoutSampler, retry
4444
import utilities.general
4545

@@ -328,9 +328,15 @@ def login_with_user_password(api_address: str, user: str, password: str | None =
328328
if password:
329329
login_command += f" -p '{password}'"
330330

331-
_, out, _ = run_command(command=shlex.split(login_command), hide_log_command=True)
331+
_, out, err = run_command(command=shlex.split(login_command), hide_log_command=True)
332332

333-
return "Login successful" in out
333+
if err and err.lower().startswith("error"):
334+
raise ClusterLoginError(user=user)
335+
336+
if re.search(r"Login successful|Logged into", out):
337+
return True
338+
339+
return False
334340

335341

336342
@cache

0 commit comments

Comments
 (0)