From 82654af0b77e3ce51562fe1c712fa35abdf5b6ce Mon Sep 17 00:00:00 2001 From: michael wilson Date: Thu, 2 May 2024 13:37:23 -0700 Subject: [PATCH] Update synchronized_start_timeout to use nanoseconds --- CHANGELOG.md | 4 ++++ beaker/data_model/experiment_spec.py | 10 ++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 735f43b..336159e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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`. diff --git a/beaker/data_model/experiment_spec.py b/beaker/data_model/experiment_spec.py index ce52894..2357326 100644 --- a/beaker/data_model/experiment_spec.py +++ b/beaker/data_model/experiment_spec.py @@ -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 @@ -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),