Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies = [
]

[project.optional-dependencies]
remote = ["kfp>=2.5.0", "kfp-kubernetes>=2.0.0", "s3fs>=2024.12.0"]
remote = ["kfp>=2.5.0", "kfp-kubernetes>=2.0.0", "s3fs>=2024.12.0", "kubernetes>=30.0.0"]
distro = ["opentelemetry-api", "opentelemetry-exporter-otlp", "aiosqlite", "ollama", "uvicorn"]
dev = [
"llama-stack-provider-ragas[distro]",
Expand Down
34 changes: 20 additions & 14 deletions src/llama_stack_provider_ragas/eval_remote.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# TODO: decide how to treat these imports & possibly an extras_require
import logging
import subprocess
import uuid
from typing import Any

Expand Down Expand Up @@ -38,14 +36,7 @@ def __init__(
try:
import kfp

result = subprocess.run(
["oc", "whoami", "-t"],
capture_output=True,
text=True,
check=True,
timeout=5,
)
token = result.stdout.strip()
token = self._get_token()
if not token:
raise RagasEvaluationError(
"No token found. Please run `oc login` and try again."
Expand All @@ -70,10 +61,6 @@ def __init__(
raise RagasEvaluationError(
"Kubeflow Pipelines SDK not available. Install with: pip install .[remote]"
) from e
except subprocess.CalledProcessError as e:
raise RagasEvaluationError(
f"Failed to get OpenShift token. Command failed with exit code {e.returncode}: {e.stderr.strip()}"
) from e
except requests.exceptions.RequestException as e:
raise RagasEvaluationError(
f"Failed to connect to Kubeflow Pipelines server at {self.config.kubeflow_config.pipelines_endpoint}, "
Expand All @@ -84,6 +71,25 @@ def __init__(
"Failed to initialize Kubeflow Pipelines client."
) from e

def _get_token(self) -> str:
try:
from kubernetes.client.configuration import Configuration
from kubernetes.config.kube_config import load_kube_config

config = Configuration()
load_kube_config(client_configuration=config)
token = str(config.api_key["authorization"].split(" ")[-1])
except ImportError as e:
raise RagasEvaluationError(
"Kubernetes client is not installed. Install with: pip install .[remote]"
) from e
except Exception as e:
raise RagasEvaluationError(
"Failed to get OpenShift token. Please run `oc login` and try again."
) from e

return token

async def run_eval(
self,
benchmark_id: str,
Expand Down
3 changes: 3 additions & 0 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.