Skip to content

chore: enhance API reference for SDK clients#262

Open
Priyanshu-u07 wants to merge 2 commits intokubeflow:mainfrom
Priyanshu-u07:docs/api-reference
Open

chore: enhance API reference for SDK clients#262
Priyanshu-u07 wants to merge 2 commits intokubeflow:mainfrom
Priyanshu-u07:docs/api-reference

Conversation

@Priyanshu-u07
Copy link

Description

This PR improves the API reference documentation for Kubeflow SDK clients by
expanding docstrings with clearer descriptions, parameters, return types,
error details, and practical usage examples.

These documentation-only changes improve developer experience without
modifying any runtime behavior or public APIs.

Fixes #260

Checklist:

  • Docs included if any changes are user facing

@google-oss-prow google-oss-prow bot requested review from fege and szaher February 3, 2026 18:46
@google-oss-prow
Copy link
Contributor

[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 andreyvelich 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

@github-actions
Copy link
Contributor

github-actions bot commented Feb 3, 2026

🎉 Welcome to the Kubeflow SDK! 🎉

Thanks for opening your first PR! We're happy to have you as part of our community 🚀

Here's what happens next:

  • If you haven't already, please check out our Contributing Guide for repo-specific guidelines and the Kubeflow Contributor Guide for general community standards
  • Our team will review your PR soon! cc @kubeflow/kubeflow-sdk-team

Join the community:

Feel free to ask questions in the comments if you need any help or clarification!
Thanks again for contributing to Kubeflow! 🙏

@Priyanshu-u07 Priyanshu-u07 changed the title docs: enhance API reference for SDK clients chore: enhance API reference for SDK clients Feb 3, 2026
Copilot AI review requested due to automatic review settings February 26, 2026 23:05
Copy link
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

This PR enhances the auto-generated API reference for Kubeflow SDK clients by expanding method docstrings with clearer descriptions, return/raise details, and runnable usage examples (aimed at improving developer experience without changing intended runtime behavior).

Changes:

  • Expanded docstrings across TrainerClient, OptimizerClient, and ModelRegistryClient with richer parameter/return/raise sections.
  • Added practical usage examples for common client workflows (list/get/create/wait/delete/logs/events).
  • Clarified semantics around defaults (timeouts, polling, inferred connection settings).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 9 comments.

File Description
kubeflow/trainer/api/trainer_client.py Docstring expansions and examples for Trainer client methods; one type-annotation change introduced.
kubeflow/optimizer/api/optimizer_client.py Docstring expansions and examples for Optimizer client methods (optimize/jobs/logs/results/wait/events).
kubeflow/hub/api/model_registry_client.py Docstring expansions and examples for Model Registry operations and connection options.

Comment on lines +343 to +347

client = TrainerClient()
job = client.wait_for_job_status(
name="my-job",
status={constants.TRAINJOB_COMPLETE}
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

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

In the example, from kubeflow.trainer import constants imports the kubeflow.trainer.constants package (whose __init__.py is empty), so constants.TRAINJOB_COMPLETE will not exist; import the constants module/values instead (e.g., from kubeflow.trainer.constants import constants or from kubeflow.trainer.constants.constants import TRAINJOB_COMPLETE).

Copilot uses AI. Check for mistakes.
}

# Define objective
objectives = [Objective(name="accuracy", goal=0.99, type="maximize")]
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

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

The example creates Objective(name=..., goal=..., type=...), but Objective is defined with fields metric and direction, so this snippet will raise TypeError if copied; update the example to match Objective(metric="accuracy", direction="maximize") (or similar).

Suggested change
objectives = [Objective(name="accuracy", goal=0.99, type="maximize")]
objectives = [Objective(metric="accuracy", direction="maximize")]

Copilot uses AI. Check for mistakes.
Comment on lines 110 to 111
job_name = client.optimize(
trial_template=tpl,
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

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

The optimize() example passes trial_template=tpl but tpl is not defined in the example, so readers can't run it as-is; either show how to construct a TrainJobTemplate or rename it to a clearly-marked placeholder (e.g., trial_template=my_template).

Suggested change
job_name = client.optimize(
trial_template=tpl,
# Assume `my_template` is a TrainJobTemplate defined elsewhere
job_name = client.optimize(
trial_template=my_template,

Copilot uses AI. Check for mistakes.
Returns:
A Result object containing the best hyperparameters and metrics, or None if
no best trial is available yet.
Optional[kubeflow.optimizer.types.Result]: A object containing the
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

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

Grammar: "A object" should be "An object" in the return description.

Suggested change
Optional[kubeflow.optimizer.types.Result]: A object containing the
Optional[kubeflow.optimizer.types.Result]: An object containing the

Copilot uses AI. Check for mistakes.
Comment on lines 128 to +130
Returns:
List of created OptimizationJobs. If no OptimizationJob exist,
an empty list is returned.
list[kubeflow.optimizer.types.OptimizationJob]: A list of created
OptimizationJobs. If no jobs exist, an empty list is returned.
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

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

The docstring return types reference kubeflow.optimizer.types.OptimizationJob, but kubeflow.optimizer.types is not a public module exporting these symbols (they live under kubeflow.optimizer.types.optimization_types and are also re-exported from kubeflow.optimizer); use a resolvable fully-qualified path to avoid broken/incorrect API references.

Copilot uses AI. Check for mistakes.

Returns:
A list of Event objects associated with the OptimizationJob.
list[kubeflow.trainer.types.Event]: A list of Event objects
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

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

The return type in the docstring points to kubeflow.trainer.types.Event, but Event is defined in kubeflow.trainer.types.types (and imported here from that module), so the displayed fully-qualified type will be incorrect; update the reference to a resolvable path (or just list[Event]).

Suggested change
list[kubeflow.trainer.types.Event]: A list of Event objects
list[Event]: A list of Event objects

Copilot uses AI. Check for mistakes.

def list_jobs(self, runtime: types.Runtime | None = None) -> list[types.TrainJob]:
"""List of the created TrainJobs. If a runtime is specified, only TrainJobs associated with
def list_jobs(self, runtime: Optional[types.Runtime] = None) -> list[types.TrainJob]:
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

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

list_jobs uses Optional[...] in its type annotation but Optional is not imported (and this module does not use postponed evaluation of annotations), which will raise a NameError at import time; import Optional from typing or switch back to types.Runtime | None.

Suggested change
def list_jobs(self, runtime: Optional[types.Runtime] = None) -> list[types.TrainJob]:
def list_jobs(self, runtime: types.Runtime | None = None) -> list[types.TrainJob]:

Copilot uses AI. Check for mistakes.
Comment on lines 80 to +82
Returns:
A list of available training runtimes. If no runtimes exist, an empty list is returned.
list[kubeflow.trainer.types.Runtime]: A list of available training
runtimes. If no runtimes exist, an empty list is returned.
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

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

The docstring return types reference kubeflow.trainer.types.Runtime, but kubeflow.trainer.types does not export these symbols (they live in kubeflow.trainer.types.types and are also re-exported from kubeflow.trainer), so the fully-qualified type names shown in the API reference will be misleading; use a resolvable path like kubeflow.trainer.Runtime/kubeflow.trainer.types.types.Runtime (and apply consistently for TrainJob/Event as well).

Copilot uses AI. Check for mistakes.
Comment on lines 272 to 277
from kubeflow.optimizer import OptimizerClient, constants

client = OptimizerClient()
job = client.wait_for_job_status(
name="my-opt-job",
status={constants.OPTIMIZATION_JOB_COMPLETE}
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

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

In the example, from kubeflow.optimizer import constants imports the kubeflow.optimizer.constants package (empty __init__.py), so constants.OPTIMIZATION_JOB_COMPLETE will not exist; import the constants module/values instead (e.g., from kubeflow.optimizer.constants import constants).

Suggested change
from kubeflow.optimizer import OptimizerClient, constants
client = OptimizerClient()
job = client.wait_for_job_status(
name="my-opt-job",
status={constants.OPTIMIZATION_JOB_COMPLETE}
from kubeflow.optimizer import OptimizerClient
from kubeflow.optimizer.constants import constants
client = OptimizerClient()
job = client.wait_for_job_status(
name="my-opt-job",
status={constants.OPTIMIZATION_JOB_COMPLETE},

Copilot uses AI. Check for mistakes.
Signed-off-by: Priyanshu-u07 <connect.priyanshu8271@gmail.com>
Signed-off-by: Priyanshu Kumar <connect.priyanshu8271@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enhance API Reference

2 participants