Skip to content

fix: improve TrainerClient code quality and documentation - #645

Open
vjkumar2756 wants to merge 1 commit into
kubeflow:mainfrom
vjkumar2756:fix/runtime-type-annotations
Open

vjkumar2756 wants to merge 1 commit into
kubeflow:mainfrom
vjkumar2756:fix/runtime-type-annotations

Conversation

@vjkumar2756

Copy link
Copy Markdown

Description

This PR addresses #640 by improving the TrainerClient implementation.

Changes made

  • Added missing return type annotations for improved type safety.
  • Replaced if not backend_config with if backend_config is None for more explicit None checking.
  • Improved docstrings for better clarity and consistency.
  • Enhanced error messages for unsupported backend configurations.
  • Improved overall code readability and maintainability.

Testing

  • Verified that existing functionality remains unchanged.
  • Ran the relevant test suite to ensure all tests pass.

Fixes #640

Signed-off-by: vjkumar2756 <vjkumar2756@gmail.com>
@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 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

@lntutor lntutor left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The proposed get_runtime_packages(...) -> str annotation does not match the backend implementations. LocalProcessBackend.get_runtime_packages() returns local_runtime.trainer.packages, and kubeflow/trainer/backends/localprocess/backend_test.py explicitly asserts it is a list; the container and Kubernetes implementations print their results and return None. Please use the verified cross-backend return type (for example list[str] | None, if package entries are strings) or leave this method unannotated until the backend interface is made consistent. Also add a delegation test for TrainerClient so the public annotation is protected by the actual API behavior.

@andreyvelich

Copy link
Copy Markdown
Member

@vjkumar2756 Sorry for the delay, can you rebase this PR, so we can merge it?
/ok-to-test

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Ready to Merge

Development

Successfully merging this pull request may close these issues.

Enhance type safety and exception messages in TrainerClient

3 participants