Skip to content

fix(trainer): add missing type hints to LocalJob class#342

Open
codebyNJ wants to merge 2 commits intokubeflow:mainfrom
codebyNJ:fix/localprocess-job-type-hints
Open

fix(trainer): add missing type hints to LocalJob class#342
codebyNJ wants to merge 2 commits intokubeflow:mainfrom
codebyNJ:fix/localprocess-job-type-hints

Conversation

@codebyNJ
Copy link

@codebyNJ codebyNJ commented Mar 1, 2026

What this PR does / why we need it:

Adds comprehensive type hints and improves documentation for the LocalJob class in the localprocess backend. The class was missing type annotations on __init__ parameters (name, execution_dir, env, dependencies), all properties (stdout, success, status, returncode, creation_time, completion_time), and methods (run, cancel, stream_logs). Docstrings also had redundant type info in Args sections instead of relying on the signature annotations.

This aligns the code with the project's AGENTS.md guidelines:

"All Python code MUST include type hints and return types."

Changes:

  • Add type hints to all __init__ parameters (notably name: str, execution_dir: str | None, env: dict[str, str] | None, dependencies: list[LocalJob] | None)
  • Add return type annotations to all properties and methods
  • Fix tuple[str] to correct tuple[str, ...] for variadic tuple type
  • Update docstrings to Google style without redundant type annotations
  • Add from __future__ import annotations for forward reference support
  • Import Iterator from collections.abc for stream_logs return type

Checklist:

  • Docs included if any changes are user facing
  • Tests pass (18/18 in localprocess/backend_test.py)
  • ruff format --check passes
  • Follows Conventional Commits format

Copilot AI review requested due to automatic review settings March 1, 2026 08:43
@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 Mar 1, 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! 🙏

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

Adds missing type annotations and updates docstrings for LocalJob in the localprocess backend to better align with the repo’s typed-Python guidelines and improve readability/IDE support.

Changes:

  • Added from __future__ import annotations and updated imports to support forward references and iterator typing.
  • Added/updated type hints for LocalJob.__init__, properties, and methods (including fixing tuple[str] to tuple[str, ...]).
  • Refreshed docstrings to avoid redundant type info and better describe behavior.

codebyNJ added 2 commits March 1, 2026 15:02
Signed-off-by: codebyNJ <nijeesh10th@gmail.com>
…y: Nijeesh NJ <nijeesh10th@gmail.com>

Signed-off-by: codebyNJ <nijeesh10th@gmail.com>
@codebyNJ codebyNJ force-pushed the fix/localprocess-job-type-hints branch from bfdd287 to 4bed199 Compare March 1, 2026 09:32
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