-
Notifications
You must be signed in to change notification settings - Fork 172
fix: added usages guide with examples to options reference #388 #432
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,6 +1,205 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Options Reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ================= | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Options let to customize how a TrainJob is created and executed. Pass them as a list to the '''options''' parameter of the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| :py:meth:`kubeflow.trainer.TrainerClient.train` method. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .. code-block:: python | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from kubeflow.trainer import TrainerClient, CustomTrainer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from kubeflow.trainer.options import Name, Labels, Annotations | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| trainer_client = TrainerClient() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| job_id = trainer_client.train( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| trainer=CustomTrainer(func=train_function), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| options=[ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Name("my-train-job"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Labels({"team": "ml", "env": "prod"}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Annotations({"note": "experiment-42"}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .. note:: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Not all options work with every backend. Each option documents | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| which backends it supports. An unsupported option will raise a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| `ValueError` at runtime. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| `ValueError` at runtime. | |
| ``ValueError`` at runtime. |
Copilot
AI
Mar 29, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Annotations description is missing a space before the inline literal ("metadata(metadata.annotations)"); add the space so the text renders/readably parses as "metadata (metadata.annotations)".
| Add annotations to the TrainJob resource metadata(``metadata.annotations``). Only supported on the Kubernetes backend. | |
| Add annotations to the TrainJob resource metadata (``metadata.annotations``). Only supported on the Kubernetes backend. |
Copilot
AI
Mar 29, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The TrainerCommand restrictions line uses incorrect reST markup (''...'' and mismatched quotes) and inconsistent capitalization ("Can Only"); use consistent inline-literal/class markup (e.g., CustomTrainerContainer, CustomTrainer, BuiltinTrainer) and "can only".
| Can Only be used with ''CustomTrainerContainer'' not with ''CustomTrainer''' or ''BuiltinTrainer''. | |
| Can only be used with ``CustomTrainerContainer`` and not with ``CustomTrainer`` or ``BuiltinTrainer``. |
Copilot
AI
Mar 29, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The TrainerArgs section is inaccurate: the option overrides .spec.trainer.args and is only valid with CustomTrainerContainer on the Kubernetes backend (per the implementation), but the text implies it appends args generically.
| Append extra arguments to the trainer container command. | |
| .. code-block:: python | |
| from kubeflow.trainer import TrainerClient, CustomTrainer | |
| from kubeflow.trainer.options import TrainerArgs | |
| trainer_client = TrainerClient() | |
| job_id = trainer_client.train( | |
| trainer=CustomTrainer(func=train_function), | |
| Override the trainer container arguments (``spec.trainer.args``). Only supported on the **Kubernetes backend** with ``CustomTrainerContainer``. | |
| .. code-block:: python | |
| from kubeflow.trainer import TrainerClient, CustomTrainerContainer | |
| from kubeflow.trainer.options import TrainerArgs | |
| trainer_client = TrainerClient() | |
| job_id = trainer_client.train( | |
| trainer=CustomTrainerContainer(image="my-image:latest"), |
Copilot
AI
Mar 29, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The TrainerArgs example uses CustomTrainer (func-based), but TrainerArgs raises ValueError unless the trainer is a CustomTrainerContainer; update the example to use CustomTrainerContainer (and show args consistent with that).
| from kubeflow.trainer import TrainerClient, CustomTrainer | |
| from kubeflow.trainer.options import TrainerArgs | |
| trainer_client = TrainerClient() | |
| job_id = trainer_client.train( | |
| trainer=CustomTrainer(func=train_function), | |
| from kubeflow.trainer import TrainerClient, CustomTrainerContainer | |
| from kubeflow.trainer.options import TrainerArgs | |
| trainer_client = TrainerClient() | |
| job_id = trainer_client.train( | |
| trainer=CustomTrainerContainer(image="my-image:latest"), |
Copilot
AI
Mar 29, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The RuntimePatch description runs two sentences together and uses inconsistent quoting (''Kubernetes backend''); add a period after the spec.runtimePatches clause and use consistent markup (e.g., Kubernetes backend or KubernetesBackend).
| Apply structured patches to the TrainJob (``spec.runtimePatches``) Use this for advanced Kubernetes-level customisation such as adding init containers, volumes, or tolerations. Only supported on the ''Kubernetes backend''. | |
| Apply structured patches to the TrainJob (``spec.runtimePatches``). Use this for advanced Kubernetes-level customisation such as adding init containers, volumes, or tolerations. Only supported on the **Kubernetes backend**. |
Copilot
AI
Mar 27, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The “TrainerCommand” section text says it overrides .spec.trainer.command and only works with CustomTrainerContainer, but the example below shows a RuntimePatch applied to a CustomTrainer; either update the example to demonstrate TrainerCommand with CustomTrainerContainer or move/rename this section to document RuntimePatch instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be a blank line between the paragraph ending with the :py:meth: role and the
.. code-block::directive; without it Sphinx can emit an "Explicit markup" warning and render incorrectly.