Skip to content

Commit

Permalink
Merge pull request #273 from allenai/michaelw/sync-nanos
Browse files Browse the repository at this point in the history
Update `synchronized_start_timeout` to use nanoseconds
  • Loading branch information
epwalsh authored May 2, 2024
2 parents 88529b9 + 82654af commit b1d4998
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ use patch releases for compatibility fixes instead.

## Unreleased

### Fixed

- Update `synchronized_start_timeout` to send nanoseconds to the Beaker server instead of a string.

## [v1.26.8](https://github.com/allenai/beaker-py/releases/tag/v1.26.8) - 2024-05-01

- Added new fields `JobStatus.ready`, `JobExecution.replica_rank`, and `JobExecution.replica_group_id`.
Expand Down
10 changes: 8 additions & 2 deletions beaker/data_model/experiment_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,11 +403,11 @@ class TaskSpec(BaseModel, frozen=False):
Determines if whole experiment should fail if this task failures.
"""

synchronized_start_timeout: Optional[str] = None
synchronized_start_timeout: Optional[int] = None
"""
If set, jobs in the replicated task will wait to start, up to the specified timeout,
until all other jobs are also ready. If the timeout is reached, the job will be canceled.
Must be greater than zero and less than or equal to 48 hours.
Represented using nanoseconds, must be greater than zero and less than or equal to 48 hours.
"""

@classmethod
Expand Down Expand Up @@ -472,6 +472,12 @@ def new(
else:
constraints = Constraints(cluster=[cluster])

# Allow setting the timeout using seconds, rather than nanoseconds.
synchronized_start_timeout_str = kwargs.pop("synchronized_start_timeout", None)
if synchronized_start_timeout_str is not None:
synchronized_start_timeout = int(synchronized_start_timeout_str * 1_000_000_000)
kwargs["synchronized_start_timeout"] = synchronized_start_timeout

return TaskSpec(
name=name,
image=ImageSource(beaker=beaker_image, docker=docker_image),
Expand Down

0 comments on commit b1d4998

Please sign in to comment.