← Back to Pull requests

feat(pipelines): add pipelines client module #468

Closed
unknown closed this pull request without merging on Nov 11, 2026 06:55 UTC
View on GitHub
unknown unknown commented on Oct 23, 2026 14:00 UTC
Author

Fixes #182

This adds a pipelines client module that wraps kubeflow.pipelines.PipelinesClient from SDK 0.5.0. With it an agent can find registered pipelines, start a run, follow it, read the task logs, and stop or retry a run. I kept to the tool list in the issue and followed the trainer module layout and CONVENTIONS.md.

Tools

| Tool | What it does | How it's done | Persona |
|---|---|---|---|
| list_pipelines | Lists registered pipelines, paged | PipelinesClient.list_pipelines | readonly |
| get_pipeline | One pipeline plus its last 20 versions | get_pipeline, list_pipeline_versions | readonly |
| list_pipeline_runs | Runs, filter by pipeline, experiment or status | list_runs | readonly |
| get_pipeline_run | State, error, params and task states of a run | get_run | readonly |
| get_pipeline_logs | Logs of the task pods of a run | pod names from get_run, then read_namespaced_pod_log | readonly |
| create_pipeline_run | Starts a run of a registered pipeline | get_pipeline, then run(Pipeline, ...) | data-scientist |
| stop_pipeline_run | Stops a running run | kfp_client().terminate_run | ml-engineer |
| retry_pipeline_run | Retries a failed or canceled run | kfp run API run_service_retry_run | ml-engineer |

The three write tools return a preview first and only act with confirmed=True, same as the trainer tools.

Things the SDK doesn't cover

PipelinesClient has no method for logs, stop or retry, so:

  • get_pipeline_logs reads the pod names KFP stores on each task, then those pods' logs from the main container (falls back to the default container). It only reads pods that belong to that run.

  • stop_pipeline_run uses the public kfp_client().terminate_run(run_id).

  • retry_pipeline_run uses the private kfp_client()._run_api.run_service_retry_run(run_id); I pinned it in sdk_contracts_test.py so a kfp change shows up as a failing test.
  • Safety

  • Namespace is resolved first, checked with check_namespace_allowed(), then handed to the client. Fails closed if the default can't be resolved.

  • Only registered pipelines are passed to run() as a Pipeline object. File paths and names ending in .yaml, .yml, .zip, .tgz, .tar.gz are rejected, because the SDK would otherwise read that file from the server's disk.

  • URL and token come only from env vars (KUBEFLOW_MCP_PIPELINES_URL, KUBEFLOW_MCP_PIPELINES_TOKEN), so an agent can't point the server at another endpoint.

  • KFP runs don't take labels, so there is no MCP ownership check like the trainer tools have. Stop and retry are therefore ml-engineer, the preview says it acts on any run in the namespace, and all three write tools are listed in docs/design/mutation-safety.md.
  • The pipelines extra

    kubeflow[pipelines] pulls kfp 2.17, which needs kubernetes<31, and this repo pins kubernetes>=35, so the lock can't resolve (open KFP issue: kubeflow/pipelines#13390). kfp is imported lazily, the server starts fine without it, and the pipelines tools return a clear "install kubeflow[pipelines]" error. The supported install path (pip install . 'kubeflow[pipelines]') is documented in the README.

    Tests

    Tests mock PipelinesClient, so they run in CI without kfp or a cluster; the module sits at ~96% coverage. sdk_contracts_test.py pins the real kfp calls, but it only runs where kfp is installed.

    Diff: 424 lines (+318 / -106) across 5 files Reviewer: abhijeet-dhumal Review duration: 26935m
    All Vouch review confidence checks passed
    Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.45 · 424 lines diff across 5 files
    0.45
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.362
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #468"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 45.1% (MEDIUM) · Higher = larger blast radius
    45.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 17.8% · Safe to merge
    17.8%