-
Notifications
You must be signed in to change notification settings - Fork 172
fix(trainer): validate polling_interval strictly less than timeout (#400) #417
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -460,9 +460,16 @@ def wait_for_job_status( | |
| if not status.issubset(job_statuses): | ||
| raise ValueError(f"Expected status {status} must be a subset of {job_statuses}") | ||
|
|
||
| if polling_interval > timeout: | ||
| if polling_interval >= timeout: | ||
| raise ValueError( | ||
| f"Polling interval {polling_interval} must be less than timeout: {timeout}" | ||
| f"polling_interval ({polling_interval}) must be strictly less than " | ||
| f"timeout ({timeout})" | ||
| ) | ||
|
|
||
| if polling_interval <= 0 or timeout <= 0: | ||
| raise ValueError( | ||
| f"polling_interval ({polling_interval}) and timeout ({timeout}) " | ||
| f"must both be positive" | ||
| ) | ||
|
|
||
| for _ in range(round(timeout / polling_interval)): | ||
|
Comment on lines
+463
to
475
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -226,9 +226,16 @@ def wait_for_job_status( | |
| if _job is None: | ||
| raise ValueError(f"No TrainJob with name {name}") | ||
|
|
||
| if polling_interval > timeout: | ||
| if polling_interval >= timeout: | ||
| raise ValueError( | ||
| f"Polling interval {polling_interval} must be less than timeout: {timeout}" | ||
| f"polling_interval ({polling_interval}) must be strictly less than " | ||
| f"timeout ({timeout})" | ||
| ) | ||
|
|
||
| if polling_interval <= 0 or timeout <= 0: | ||
| raise ValueError( | ||
| f"polling_interval ({polling_interval}) and timeout ({timeout}) " | ||
| f"must both be positive" | ||
| ) | ||
|
|
||
| for _ in range(round(timeout / polling_interval)): | ||
|
Comment on lines
+229
to
241
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider validating
polling_interval > 0(andtimeout > 0) here as well:polling_interval=0currently causes a tight loop (no sleep) until timeout, which can hammer the API and CPU; raisingValueErrorfor non-positive values avoids this.