kubeflow / kubeflow/sdk

Enhance type safety and exception messages in TrainerClient

Open Beginner friendly
#640 0 comments 0 reactions 0 assignees View on GitHub
kind/feature needs-triage
Dominant language
Python
Stars
148
Forks
262
Avg merge
1d 2h
Merged PRs (30d)
1

Description

### What you would like to be added?

The trainer_client.py class can be improved by enhancing its type annotations and providing clearer error messages without changing its existing behavior.

The proposed improvements include:

Add explicit return type annotations to public methods that currently lack them (after verifying the backend implementations) , such as get_runtime_packages() and delete_job() .

Improve the ValueError raised for unsupported backend configurations by reporting the configuration type instead of the object's string representation. This will make debugging easier and provide more actionable error messages .

Ensure the public API remains consistent with the rest of the codebase by using complete type annotations.

### Why is this needed?

The trainer_client.py API is part of the public SDK, so consistent type annotations and clear error messages improve the developer experience.

Currently:

Some public methods do not have explicit return type annotations, making the API less consistent and reducing the effectiveness of static type checkers and IDE autocompletion.

The ValueError raised for unsupported backend configurations displays the object representation instead of its type, which can make debugging more difficult.

### Love this feature?

Yes! I'd be happy to work on this improvement and submit a pull request if the proposal is accepted.

Contributor guide

Open the contributing guide

Research direction

Start with trainer_client.py and inspect the backend implementations for get_runtime_packages() and delete_job() to confirm their return types. Review the unsupported-backend ValueError and make its message report the configuration type without changing behavior. Done means the public methods have complete return annotations and the error is clearer.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend-api-design
Issue type
Refactor
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.