Skip to content

Integrate the Kubeflow Pipelines with Kubeflow SDK #125

Closed

Description

@andreyvelich

What you would like to be added?

The Kubeflow SDK goal is to provide unified interface to interact with Kubeflow tools, and we would like to create PipelinesClient() to give users ability to create ML pipelines, as we discussed at the last Pipelines WG.

Given that migration of kfp into kubeflow SDK might take time, @mprahl and @HumairAK proposed that we install kfp in the Kubeflow SDK packages, and create create a thin wrapper on top of the KFP Client:

class PipelinesClient(kfp.Client):
  ....

Additionally, we still want to install Kubeflow SDK as part of kfp if users define it in their components: kubeflow/pipelines#12027. @Prateekbala has already opened PR here: kubeflow/pipelines#12368

I believe, that might help us to drive the integration forward and achieve the long-term goal of unified Python SDK to manage AI workloads on Kubernetes.

cc @kubeflow/wg-pipeline-leads @kubeflow/kubeflow-sdk-team @franciscojavierarceo @kubeflow/kubeflow-trainer-team

Why is this needed?

Kubeflow SDK should support Kubeflow Pipelines.

Love this feature?

Give it a 👍 We prioritize the features with most 👍

Activity

  1. andreyvelich commented on Oct 27, 2025

    @andreyvelich
    MemberAuthor

    /area pipelines

  2. Anjankumar-Developer commented on Nov 27, 2025

    @Anjankumar-Developer

    /assign

  3. Shekharrajak commented on Jan 6, 2026

    @Shekharrajak
    Member

    Did we start the KEP for this ?

  4. andreyvelich commented on Jan 6, 2026

    @andreyvelich
    MemberAuthor

    We haven't started work on this yet.
    @Anjankumar-Developer Are you still interested to move this forward?

  5. Shekharrajak commented on Jan 6, 2026

    @Shekharrajak
    Member

    Let me think and brainstorm on this and will come up with KEP draft.

  6. EncHawk commented on Jan 17, 2026

    @EncHawk

    Hello @andreyvelich I would love to have a crack at this. I will post my approach as I continue to research the issue.

  7. andreyvelich commented on Feb 11, 2026

    @andreyvelich
    MemberAuthor

    Thanks @EncHawk for helping with pipelines-components integration!

    @kramaranya will help with migration of KFP client into Kubeflow SDK

    /assign @kramaranya

  8. MStokluska commented on Feb 16, 2026

    @MStokluska
    Contributor

    /assign

  9. kramaranya commented on Feb 16, 2026

    @kramaranya
    Contributor

    @MStokluska will work on the integration from our side!
    /unassign @Anjankumar-Developer @kramaranya

  10. MStokluska commented on Feb 25, 2026

    @MStokluska
    Contributor

    Hey @andreyvelich @kramaranya @astefanutti

    I looked into it and I tried to keep it as condense as possible, let me know please if you think it would be more appropriate to move this conversation to a document instead.

    Proposal is to add a PipelinesClient to the Kubeflow SDK that wraps kfp.Client, following the established pattern of ModelRegistryClient (kubeflow[hub]).

    Install: pip install 'kubeflow[pipelines]'

    Import: from kubeflow.pipelines import PipelinesClient, dsl, compiler, components

    The pyproject extra:

    pipelines = ["kfp[kubernetes]>=2.0.0"]
    • One SDK for the full pipeline flow: author (DSL) → compile → upload → run → monitor.
    • Wrapper, not fork: PipelinesClient delegates to kfp.Client under the hood. No duplicated logic, no divergence from upstream KFP.
    • Consistent API: name-first design (like ModelRegistryClient), aligned constructor (base_url, port, user_token), same naming conventions (get_*, list_*, create_*, delete_*).
    • Simpler for most users: hides ID-centric KFP APIs behind name-based methods. Pipelines, experiments, and pipeline versions are resolved by name throughout — including when creating runs and recurring runs (pipeline_name, experiment_name, auto-version). After creation, runs are tracked by run_id and recurring runs by recurring_run_id (display names aren't unique in KFP).
    • Consistent constructor: base_url, port, user_token, is_secure, custom_ca, namespace — aligned with ModelRegistryClient and other SDK clients. Namespace defaults to None (not "kubeflow").
    • Full author-to-monitor flow from one SDK: Re-export dsl, compiler, and components at module level so users can author, compile, upload, run, and monitor pipelines without mixing kfp and kubeflow imports.
    • Clean API surface: Drop legacy aliases (*_job), generated server APIs, and advanced auth params. Keep the wrapper focused on the common workflow; power users can use kfp.Client directly.
    • wait_for_run_status: Improve on KFP's wait_for_run_completion by accepting a flexible status set (matching Trainer/Optimizer's wait_for_job_status pattern).

    User experience

    The envisioned flow for a user working with pipelines through the Kubeflow SDK:

    1. Install — pip install 'kubeflow[pipelines]' adds the pipelines client and the KFP authoring tools (DSL, compiler) in one step.
    2. Author — Write pipeline components and pipelines using Python decorators (@dsl.component, @dsl.pipeline), all imported from the Kubeflow SDK.
    3. Compile — Compile the pipeline to a portable YAML artifact, either explicitly or as part of the upload step.
    4. Connect — Create a PipelinesClient pointing at the KFP API server with a familiar constructor (base_url, optional auth).
    5. Upload — Push the compiled pipeline (or a Python function directly) to the server. Manage versions as needed.
    6. Run — Trigger a one-off run or set up a recurring schedule (cron / interval). Refer to pipelines and experiments by name.
    7. Monitor — List runs, wait for completion, inspect results, archive or clean up.

    Users who need advanced KFP features (local execution, raw server API, IAP auth) can still use kfp directly alongside the wrapper.

    Why the kfp[kubernetes] extra

    KFP has three extras:

    extras_require={
        'all': docker + kubernetes + notebooks,
        'kubernetes': kubernetes,
        'notebooks': notebooks,
    }

    We bundle only kfp[kubernetes] because:

    • Relevant for the main use case — pipelines run on K8s; the helpers (add_node_selector, mount_pvc, use_secret_as_env, etc.) are what users need to wire tasks to nodes, storage, and secrets.
    • Lightweight — kfp-kubernetes depends only on kfp and protobuf (both already installed). No new dependency tree.
    • kfp[notebooks] is heavy — pulls in nbclient, ipykernel, jupyter_client, and the Jupyter stack. Not needed by most users.
    • kfp[all] is the heaviest — adds docker + notebooks on top. Overkill as a default.

    Users who need notebook components can install kfp[notebooks] on top; the wrapper works the same.

    After KEP-12548 (KFP SDK unification into a single kfp 3.x package), we bump to e.g. kfp[kubernetes]>=3.0.0 and re-evaluate.

    Exposed APIs

    Constructor — PipelinesClient(base_url, port, user_token, is_secure, custom_ca, namespace) — Aligned with ModelRegistryClient so all Kubeflow clients share the same connection pattern.

    Namespace — Optional parameter on the constructor (default None). In multi-user KFP deployments, experiments and pipelines are scoped per Kubernetes namespace; passing namespace tells the client which scope to operate in. For single-user deployments, users simply omit it. Individual methods can also override the namespace when needed. The raw KFP client defaults namespace to "kubeflow", which can be confusing for single-user deployments that may not have a kubeflow namespace at all. We default to None instead, letting the server handle it without forcing a namespace.

    Health / context — Lets users verify the server is reachable and check deployment mode (e.g. multi-user) before doing work.

    • get_health — Pings the KFP server healthz endpoint; returns deployment info (e.g. whether multi-user is enabled). Renamed from get_kfp_healthz.
    • set_user_namespace — Sets the namespace scope for subsequent API calls (multi-user deployments). Same name as in KFP. We already support adding namespace at init time, there are subtle differences between
      set_user_namespace vs constructor namespace (with switch namespace mid-session support being the core base for having this included).
    • get_user_namespace — Returns the currently configured namespace. Same name as in KFP.

    Experiments (name-first, ID fallback) — Experiments group runs together; essential for organizing pipeline work in KFP.

    • create_experiment
    • list_experiments
    • get_experiment
    • archive_experiment
    • unarchive_experiment
    • delete_experiment

    Pipelines (name-first, ID fallback) — Core CRUD for pipeline definitions; how users browse, inspect, and manage uploaded pipelines and their versions.

    • list_pipelines
    • get_pipeline
    • delete_pipeline
    • list_pipeline_versions
    • get_pipeline_version
    • delete_pipeline_version

    Upload — How pipeline definitions get into the system; includes convenience methods that compile a Python function and upload in one step (adding short desc to highlight diffs between them).

    • upload_pipeline — upload from a compiled package file (YAML/JSON)
    • upload_pipeline_version — upload a new version of an existing pipeline from a package file
    • upload_pipeline_from_pipeline_func — compile a @dsl.pipeline function and upload in one step
    • upload_pipeline_version_from_pipeline_func — compile and upload as a new version of an existing pipeline

    Runs — The core execution lifecycle: trigger a pipeline, monitor progress, and manage completed runs. Creating a run is name-first: run_pipeline accepts pipeline_name and experiment_name (resolved to IDs internally). When version_id is omitted, the latest pipeline version is used automatically; pass version_id explicitly to pin a specific version. After creation, each run is tracked by its run_id (run display names aren't unique in KFP, so get_run, wait_for_run_status, archive_run, etc. all take run_id).

    • run_pipeline
    • run_pipeline_from_func
    • run_pipeline_from_package
    • list_runs
    • get_run
    • wait_for_run_status
    • archive_run
    • unarchive_run
    • delete_run
    • terminate_run

    Recurring runs — Schedules that automatically create runs on a cron or interval trigger; needed for production pipelines that run periodically. Same name-first creation as runs (pipeline_name, experiment_name, auto-version resolution). After creation, managed by recurring_run_id.

    • create_recurring_run
    • list_recurring_runs
    • get_recurring_run
    • delete_recurring_run
    • enable_recurring_run
    • disable_recurring_run

    DSL re-exports (module-level, zero wrapping) — Gives users the full author → compile flow from a single SDK without needing separate kfp imports.

    • dsl (pipeline/component authoring)
    • compiler (compile to YAML)
    • components (load from YAML/URL)

    Deferred APIs

    Generated server APIs — client.pipelines.*, client.runs.*, client.experiments.*, client.recurring_runs.*, client.healthz.*, client.api_models. These come from kfp_server_api (the generated REST client). Our high-level methods already call them under the hood; exposing the raw layer would duplicate functionality.

    pipeline_spec — Internal protobuf IR that the compiler produces and the server consumes. Users don't need it for the normal flow (DSL → compile → upload → run); to me it seems that exposing it would add API surface for a format most users never touch. Power users can use kfp directly.

    Legacy aliases — delete_job, enable_job, disable_job. These are old names for the *_recurring_run methods; we unify under *_recurring_run only to keep the API clean and avoid confusing aliases.

    Advanced auth — cookies, client_id, other_client_id, other_client_secret, proxy, ssl_ca_cert, kube_context, credentials, ui_host, verify_ssl. We support user_token, is_secure, and custom_ca to cover the common cases and stay consistent with ModelRegistryClient. The rest are for niche setups (IAP, kube config, proxy); keeping them out keeps the constructor simple. Available via kfp.Client directly.

    UI / notebook helpers — URL printing and IPython display links. These are environment-specific (only useful in Jupyter/browser); not core to the pipeline lifecycle. Can be added later if there's demand.

    End-to-end example

    from kubeflow.pipelines import PipelinesClient, dsl, compiler
    
    @dsl.component
    def train(epochs: int) -> str:
        return f"trained for {epochs} epochs"
    
    @dsl.pipeline
    def my_pipeline(epochs: int = 10):
        train(epochs=epochs)
    
    client = PipelinesClient("https://ml-pipeline.example.com")
    
    # Compile + upload in one step
    client.upload_pipeline_from_pipeline_func(my_pipeline, pipeline_name="my-pipeline")
    
    # Run it — experiment and pipeline resolved by name; latest version used automatically.
    # Pass version_id= to pin a specific version. The run itself is tracked by its ID.
    run = client.run_pipeline(experiment_name="default", job_name="run-1", pipeline_name="my-pipeline")
    
    # Monitor — uses the run ID returned above
    client.wait_for_run_status(run.run_id)

    Notable gaps

    Task logs

    get_run returns run metadata and per-task details (status, timing, pod name, inputs/outputs) but not task logs. The KFP Python SDK has no get_logs or get_task_logs method — logs live in the Kubernetes pod, not in the KFP API. The KFP UI fetches them by calling the K8s API behind the scenes.

    Possible future addition: We could add a convenience method like get_task_logs(run_id, task_name) that:

    1. Calls get_run to resolve the task's pod_name from task_details.
    2. Uses the Kubernetes Python client to fetch logs from that pod.

    However, this would change the auth model: the current PipelinesClient only needs credentials for the KFP API server (base_url + user_token). Fetching pod logs requires Kubernetes API access (kubeconfig or in-cluster service account), which is a different auth flow. The client would need either a K8s client instance or additional config to reach the cluster API.

    I think this would be out of scope for the first iteration but worth considering as a follow-up — especially for users who want a single SDK for the full observe/debug cycle without switching to kubectl.

    Run events

    Every other Kubeflow SDK client that operates on Kubernetes resources exposes an events method — TrainerClient.get_job_events(name), OptimizerClient.get_job_events(name). Events provide additional clarity about state changes, scheduling failures, and errors that logs alone don't capture (e.g. pod stuck in Pending, image pull failures).

    The KFP Python SDK does not have a get_run_events method — the KFP API server does not surface Kubernetes events. Implementing this would require the same Kubernetes API access as task logs (kubeconfig or in-cluster service account), with the same auth model change.

    Possible future addition: A get_run_events(run_id) method that fetches Kubernetes events for the pods belonging to a run. This would align PipelinesClient with the rest of the SDK and give users a consistent debugging experience across Trainer, Optimizer, and Pipelines.

    Same scoping as task logs: out of scope for v1, worth considering as a follow-up.

    Potential upstream KFP improvements

    Several of the gaps above (and design decisions in the wrapper) would benefit all KFP users if contributed upstream to kfp.Client directly:

    • Task logs — KFP already knows about pods and the UI fetches logs via K8s. A native get_task_logs(run_id, task_name) on kfp.Client would remove the need for our wrapper to manage K8s auth separately (if we decided that logs gather should be implemented at the kfp client wrapper in SDK).
    • Run events — Same reasoning. KFP creates the pods; a get_run_events(run_id) would align with how Trainer and Optimizer expose events.
    • Name-first for runs and recurring runs — KFP already has name-based lookup for pipelines (get_pipeline_id) and experiments (get_experiment(experiment_name=...)). Runs and recurring runs could get the same display_name filter support possibly.
    • Name-first as the default for pipelines and experiments — The internal helpers exist but the public methods are still ID-centric. Making name the primary parameter upstream would benefit all users.
    • wait_for_run_status with a flexible status set — KFP's wait_for_run_completion hardcodes to all terminal states (succeeded, failed, skipped, error). It can't wait for non-terminal states like Running (e.g. to start tailing logs) or for a specific terminal state only (e.g. just succeeded). A wait_for_run_status(run_id, status={...}) (matching Trainer/Optimizer's wait_for_job_status) would give callers control over which states to wait for.
    • Namespace default of None instead of "kubeflow" — The current default can be confusing for single-user deployments that may not have a kubeflow namespace.

    If KFP adopts these, our wrapper becomes thinner — primarily constructor alignment, DSL re-exports, and the "one SDK" packaging. In the meantime, we implement name-first resolution in the wrapper as a bridge: pipelines, experiments, and pipeline versions are resolved by name everywhere (including when creating runs and recurring runs). After creation, runs are tracked by run_id and recurring runs by recurring_run_id (since display names aren't unique in KFP) this isn't ideal but I did not find a better alternative.

    Migration

    • Existing kfp.Client users: Adoption is optional and incremental. kfp.Client stays valid. Switch host= to base_url=; use name-first params where you currently pass IDs. After creation, runs are still tracked by run_id (display names aren't unique).
    • When KEP-12548 lands (unified kfp 3.x): We bump to kfp[kubernetes]>=3.0.0. No wrapper code changes needed; our wrapper only calls high-level Client methods and doesn't depend on kfp_server_api or kfp_pipeline_spec import paths.

    Let me know what you think!

  11. kramaranya commented on Feb 25, 2026

    @kramaranya
    Contributor

    Thanks @MStokluska for the thorough proposal. This looks good to me and I'm happy for us to move forward with this approach since the design aligns with the existing SDK patterns.

    cc @andreyvelich @astefanutti @kubeflow/wg-pipeline-leads would love your thoughts on this direction

    +1 on the potential KFP improvements section, that would give an end user consistent experience across all Kubeflow clients.
    @mprahl @HumairAK @droctothorpe @zazulam what do you all think about "Potential upstream KFP improvements" section @MStokluska proposed? Do these feel like reasonable contributions to make to kfp.Client directly?

  12. mprahl commented on Feb 25, 2026

    @mprahl

    Thanks @MStokluska for the detailed write up! This looks good to me.

    Regarding the potential upstream KFP improvements: task logs, run events, name-first APIs, and wait_for_run_status all seem like good contributions to kfp.Client. The one I'd defer is namespace default of None instead of "kubeflow" since changing this in kfp.Client would be a breaking change for existing users. We can consider it for kfp 3.x (KEP-12548).

  13. MStokluska commented on Mar 2, 2026

    @MStokluska
    Contributor

    Thank you for feedback!
    During our last Kubeflow SDK community call we have decided it will be more appropriate to create a KEP - #343

    I would appreciate a review, thanks!

  14. andreyvelich commented on May 7, 2026

    @andreyvelich
    MemberAuthor

    This is still open.
    KEP is merged here: #343
    /reopen

  15. google-oss-prow commented on May 7, 2026

    @google-oss-prow
    Contributor

    @andreyvelich: Reopened this issue.

    Details

    In response to this:

    This is still open.
    KEP is merged here: #343
    /reopen

    Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

  16. andreyvelich commented on Jul 29, 2026

    @andreyvelich
    MemberAuthor

    We can close this since PipelinesClient() is now part of Kubeflow SDK 🎉
    /close

  17. google-oss-prow commented on Jul 29, 2026

    @google-oss-prow
    Contributor

    @andreyvelich: Closing this issue.

    Details

    In response to this:

    We can close this since PipelinesClient() is not part of Kubeflow SDK 🎉
    /close

    Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions