Skip to content
Closed
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
34 changes: 34 additions & 0 deletions docs/source/train/options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,37 @@ Options Reference
.. autoclass:: kubeflow.trainer.options.ContainerPatch
:members:
:show-inheritance:

Using options with TrainerClient
===============================

The ``options`` parameter in ``TrainerClient`` allows users to customize runtime behavior
and backend-specific configurations for training jobs.

It provides flexibility to control how training jobs are executed depending on the
selected backend (e.g., Kubernetes, local, container).

Example
-------

.. code-block:: python

from kubeflow.trainer import TrainerClient, CustomTrainer

def train_fn():
print("Training...")

client = TrainerClient()

job_id = client.train(
trainer=CustomTrainer(func=train_fn),
options={
"epochs": 10,
"batch_size": 32
}
)
Comment on lines +85 to +91
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

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

The example shows options as a dictionary with {"epochs": 10, "batch_size": 32}, but the options parameter should be a list of option objects (e.g., [Name("custom-name"), Labels({...})]). According to the TrainerClient API signature and the options module design, options must be objects from kubeflow.trainer.options that can be called to modify the job specification. The current example misleads users about the correct API usage.

Copilot uses AI. Check for mistakes.

client.wait_for_job_status(job_id)

The ``options`` dictionary can include different parameters depending on the backend
and runtime configuration.
Comment on lines +95 to +96
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

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

The description states "options dictionary" and refers to "different parameters depending on the backend", but it should clarify that options is a list of option objects, and which specific option types are available for each backend (e.g., Name, Labels, Annotations, TrainerCommand, TrainerArgs for Kubernetes, and Name for other backends).

Copilot uses AI. Check for mistakes.
Loading