Skip to content

feat(sdk): add kubeflow_client PipelinesClient (phase 1). Fixes #13380#13405

Open
MStokluska wants to merge 3 commits into
kubeflow:masterfrom
MStokluska:pipelines_client
Open

feat(sdk): add kubeflow_client PipelinesClient (phase 1). Fixes #13380#13405
MStokluska wants to merge 3 commits into
kubeflow:masterfrom
MStokluska:pipelines_client

Conversation

@MStokluska
Copy link
Copy Markdown

Description of your changes:

Summary

Implements Phase 1 of the PipelinesClient (KEP-125) — a simplified, name-first Python client for Kubeflow Pipelines built directly on kfp_server_api.

  • Adds PipelinesClient class with PipelinesBackendConfig dataclass for connection configuration
  • Pipeline CRUD: upload_pipeline, get_pipeline, get_pipeline_version, list_pipelines, list_pipeline_versions, delete_pipeline
  • Run management: run (callable, YAML path, name, Pipeline/PipelineVersion objects), get_run, list_runs, wait_for_run_status (flexible target states, callbacks, token refresh)
  • Experiment management: create_experiment (idempotent), get_experiment, list_experiments, delete_experiment
  • Host auto-discovery (env var, in-cluster DNS, kubeconfig proxy)
  • Bearer token auth with refresh and retry
  • Escape hatch to kfp.Client via kfp_client property
  • Unit tests covering all public and critical private methods

Test plan

  • Unit tests pass locally: pytest -v sdk/python/kfp/kubeflow_client/pipelines_client_test.py
  • Manual verification against a live DSPA endpoint (in-cluster pod)

Issue: #13380

Checklist:

Signed-off-by: MStokluska <mstoklus@redhat.com>
Signed-off-by: MStokluska <mstoklus@redhat.com>
Copilot AI review requested due to automatic review settings May 19, 2026 07:33
@google-oss-prow
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign mprahl for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@google-oss-prow
Copy link
Copy Markdown

Hi @MStokluska. Thanks for your PR.

I'm waiting for a kubeflow member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

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.

def list_runs(
self,
*,
pipeline: str | None = None,
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding the pipeline filter in list_runs:

The pipeline parameter is included because KEP-125 specifies it as part of the Phase 1 API surface. However, it's worth noting that this filter is applied client-side - the KFP v2beta1 ListRuns API does not currently support server-side filtering by pipeline ID.

Why it's client-side: The backend stores PipelineId as a column in the run_details table (via the embedded PipelineSpec struct in backend/src/apiserver/model/pipeline_spec.go), but this field is not exposed in the runAPIToModelFieldMap (backend/src/apiserver/model/run.go), which defines the set of valid filter keys accepted by the filter query parameter.

Caveats of the current approach:

The returned page may contain fewer items than page_size (including zero items with a non-empty next_page_token) because filtering happens after the server returns a page.
Callers must continue paginating until next_page_token is empty to get complete results which IMO isn't great UX.
How this can be fixed upstream: enable server-side filtering via the existing filter protocol buffer mechanism, eliminating the pagination inconsistency. Once that backend change lands, this client method can switch to server-side filtering transparently (no public API change needed).

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Implements Phase 1 of a new kfp.kubeflow_client.PipelinesClient: a simplified, name-first Python client built directly on kfp_server_api, including pipeline CRUD, run submission (by name, callable, YAML, or model objects), experiment management, run waiting, host auto-discovery, and token-based auth (with refresh support).

Changes:

  • Added PipelinesClient + PipelinesBackendConfig with endpoint/namespace discovery and bearer-token authentication support.
  • Implemented pipeline upload/versioning, run creation/listing, experiment CRUD, and a flexible wait_for_run_status() helper.
  • Added kfp.kubeflow_client package exports, type aliases, run-state constants, and a substantial unit test suite.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
sdk/python/kfp/kubeflow_client/pipelines_client.py New PipelinesClient implementation (pipelines/runs/experiments, host discovery, auth refresh, helpers).
sdk/python/kfp/kubeflow_client/pipelines_client_test.py Unit tests for the new client and key helpers.
sdk/python/kfp/kubeflow_client/types.py Type aliases over kfp_server_api model classes for cleaner public API.
sdk/python/kfp/kubeflow_client/constants.py Lowercased run state constants + terminal-state set used by wait/filter logic.
sdk/python/kfp/kubeflow_client/init.py Package-level re-exports for the new client, types, and constants.

Comment thread sdk/python/kfp/kubeflow_client/pipelines_client.py Outdated
Comment thread sdk/python/kfp/kubeflow_client/pipelines_client.py Outdated
@andreyvelich
Copy link
Copy Markdown
Member

Thanks for this work @MStokluska! Will check this out soon

/assign @andreyvelich

Signed-off-by: MStokluska <mstoklus@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants