Skip to content

chore(trainer): improve get_job_logs docstring#438

Open
pandu992003 wants to merge 1 commit intokubeflow:mainfrom
pandu992003:docs-improve-get-job-logs
Open

chore(trainer): improve get_job_logs docstring#438
pandu992003 wants to merge 1 commit intokubeflow:mainfrom
pandu992003:docs-improve-get-job-logs

Conversation

@pandu992003
Copy link
Copy Markdown

This PR improves the documentation for the get_job_logs method in TrainerClient.

Changes:

  • Enhanced docstring with clearer explanations
  • Added usage example for real-time log streaming
  • Improved readability and formatting

This helps developers better understand how to use the log retrieval functionality.

Copilot AI review requested due to automatic review settings March 30, 2026 06:58
@google-oss-prow
Copy link
Copy Markdown
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 electronic-waste 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
Copy Markdown
Contributor

🎉 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! 🙏

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

This PR updates the TrainerClient.get_job_logs docstring to better explain log retrieval and provide a streaming usage example for developers using the Kubeflow Trainer Python API.

Changes:

  • Rewrote the get_job_logs docstring for improved clarity and formatting.
  • Added an inline usage example demonstrating real-time log streaming with follow=True.
  • Updated parameter/return descriptions and added a note about empty output.

Comment on lines +189 to +190
"""
Retrieve logs from a specific step of a TrainJob.
Copy link

Copilot AI Mar 30, 2026

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 """.

Suggested change
"""
Retrieve logs from a specific step of a TrainJob.
"""Retrieve logs from a specific step of a TrainJob.

Copilot uses AI. Check for mistakes.
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.
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

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

The Args section switches to "name (str):" style, but other TrainerClient methods in this file consistently use Google-style "name:" without repeating types; please keep the Args formatting consistent within the module (either revert here or update the surrounding methods for the same style).

Suggested change
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 uses AI. Check for mistakes.
Returns:
Iterator of log lines.
Iterator[str]: An iterator over log lines.

Copy link

Copilot AI Mar 30, 2026

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.

Suggested change
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).

Copilot uses AI. Check for mistakes.
Comment on lines +190 to +193
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.
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

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

The docstring says logs are retrieved "from a specific step", but several backends treat the default step==node-0 as a sentinel to return logs from multiple steps/nodes (not just node-0); please clarify the default/step semantics so users know what output to expect.

Copilot uses AI. Check for mistakes.
@pandu992003 pandu992003 changed the title Docs: improve get_job_logs docstring for clarity and usage docs(trainer): improve get_job_logs docstring for clarity and usage Mar 30, 2026
@pandu992003
Copy link
Copy Markdown
Author

Hi, thank you for reviewing! Please let me know if any changes are needed.

Signed-off-by: pandu992003 <vigneshbangaru69@gmail.com>
@pandu992003 pandu992003 force-pushed the docs-improve-get-job-logs branch from 78f1bbc to 1bc0368 Compare March 30, 2026 07:10
@pandu992003 pandu992003 changed the title docs(trainer): improve get_job_logs docstring for clarity and usage docs: improve get_job_logs docstring Mar 30, 2026
@pandu992003 pandu992003 changed the title docs: improve get_job_logs docstring docs(trainer): improve get_job_logs docstring Mar 30, 2026
@pandu992003 pandu992003 changed the title docs(trainer): improve get_job_logs docstring chore(trainer): improve get_job_logs docstring Mar 30, 2026
@pandu992003
Copy link
Copy Markdown
Author

Hi, thank you for reviewing! I’ve addressed all checks and updated the PR. Please let me know if any further improvements are needed.

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.

2 participants