-
Notifications
You must be signed in to change notification settings - Fork 172
chore(trainer): improve get_job_logs docstring #438
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 | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -186,28 +186,33 @@ def get_job_logs( | |||||||||||||||||||
| step: str = constants.NODE + "-0", | ||||||||||||||||||||
| follow: bool | None = False, | ||||||||||||||||||||
| ) -> Iterator[str]: | ||||||||||||||||||||
| """Get logs from a specific step of a TrainJob. | ||||||||||||||||||||
| """ | ||||||||||||||||||||
| Retrieve logs from a specific step of a TrainJob. | ||||||||||||||||||||
|
|
||||||||||||||||||||
| This method allows you to fetch logs either as a batch or stream them | ||||||||||||||||||||
| in real-time using the `follow` parameter. | ||||||||||||||||||||
|
Comment on lines
+190
to
+193
|
||||||||||||||||||||
|
|
||||||||||||||||||||
| You can watch for the logs in realtime as follows: | ||||||||||||||||||||
| ```python | ||||||||||||||||||||
| from kubeflow.trainer import TrainerClient | ||||||||||||||||||||
| Example: | ||||||||||||||||||||
| from kubeflow.trainer import TrainerClient | ||||||||||||||||||||
|
|
||||||||||||||||||||
| for logline in TrainerClient().get_job_logs(name="s8d44aa4fb6d", follow=True): | ||||||||||||||||||||
| print(logline) | ||||||||||||||||||||
| ``` | ||||||||||||||||||||
| client = TrainerClient() | ||||||||||||||||||||
|
|
||||||||||||||||||||
| # Stream logs in real-time | ||||||||||||||||||||
| for line in client.get_job_logs(name="job-id", follow=True): | ||||||||||||||||||||
| print(line) | ||||||||||||||||||||
|
|
||||||||||||||||||||
| Args: | ||||||||||||||||||||
| name: Name of the TrainJob. | ||||||||||||||||||||
| step: Step of the TrainJob to collect logs from, like dataset-initializer or node-0. | ||||||||||||||||||||
| follow: Whether to stream logs in realtime as they are produced. | ||||||||||||||||||||
| name (str): Name of the TrainJob. | ||||||||||||||||||||
| step (str): Step of the TrainJob to collect logs from | ||||||||||||||||||||
| (e.g., dataset-initializer or node-0). | ||||||||||||||||||||
| follow (bool, optional): If True, streams logs in real-time. | ||||||||||||||||||||
| Defaults to False. | ||||||||||||||||||||
|
Comment on lines
+205
to
+209
|
||||||||||||||||||||
| name (str): Name of the TrainJob. | |
| step (str): Step of the TrainJob to collect logs from | |
| (e.g., dataset-initializer or node-0). | |
| follow (bool, optional): If True, streams logs in real-time. | |
| Defaults to False. | |
| name: Name of the TrainJob. | |
| step: Step of the TrainJob to collect logs from | |
| (e.g., dataset-initializer or node-0). | |
| follow: If True, streams logs in real-time. Defaults to False. |
Copilot
AI
Mar 30, 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.
This docstring removed the Raises section, but get_job_logs can still raise (e.g., Kubernetes backend surfaces TimeoutError/RuntimeError via get_job, and LocalProcess backend raises ValueError when the job name is unknown); please document the relevant exceptions again so callers know what to handle.
| Raises: | |
| ValueError: The TrainJob with the given name does not exist (e.g., LocalProcess backend). | |
| TimeoutError: Timeout while retrieving the TrainJob or its logs (e.g., Kubernetes backend). | |
| RuntimeError: Failed to retrieve the TrainJob or its logs (e.g., Kubernetes backend). |
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 docstring starts with a blank line (the opening triple-quote is on its own line), which introduces an empty first line in generated docs/help(); align with the rest of this file by putting the one-line summary immediately after the opening """.