Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions kubeflow/trainer/backends/container/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,10 @@ def wait_for_job_status(
polling_interval: int = 2,
callbacks: list[Callable[[types.TrainJob], None]] | None = None,
) -> types.TrainJob:
if polling_interval >= timeout:
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

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

The validation uses polling_interval >= timeout but the kubernetes backend (line 463) and localprocess backend (line 229) both use polling_interval > timeout. This inconsistency means the container backend will reject valid inputs that the other two backends accept (when polling_interval equals timeout). Align this validation with the other backends by changing >= to >.

Suggested change
if polling_interval >= timeout:
if polling_interval > timeout:

Copilot uses AI. Check for mistakes.
raise ValueError(
f"Polling interval {polling_interval} must be less than timeout: {timeout}"
)
import time

end = time.time() + timeout
Expand Down
13 changes: 13 additions & 0 deletions kubeflow/trainer/backends/container/backend_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,12 @@ def mock_create_with_status(*args, **kwargs):
config={"wait_status": constants.TRAINJOB_COMPLETE, "container_exit_code": 1},
expected_error=RuntimeError,
),
TestCase(
name="polling_interval equal to timeout raises ValueError",
expected_status=FAILED,
config={"wait_status": constants.TRAINJOB_COMPLETE},
expected_error=ValueError,
),
],
)
def test_wait_for_job_status(container_backend, test_case):
Expand Down Expand Up @@ -935,6 +941,13 @@ def test_wait_for_job_status(container_backend, test_case):
container_backend.wait_for_job_status(
job_name, status={test_case.config["wait_status"]}, timeout=5, polling_interval=1
)
elif test_case.name == "polling_interval equal to timeout raises ValueError":
container_backend.wait_for_job_status(
job_name,
status={test_case.config["wait_status"]},
timeout=5,
polling_interval=5,
)

except Exception as e:
assert type(e) is test_case.expected_error
Expand Down
Loading