Skip to content

Commit ef48cc7

Browse files
committed
refactor: make timeout seconds a JobSpec property
In future scheduler/launcher work this property may need to be used multiple times, so refactor slightly to add it is a property of the `JobSpec` itself. Signed-off-by: Alex Jones <alex.jones@lowrisc.org>
1 parent b65fdc7 commit ef48cc7

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

src/dvsim/job/data.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,11 @@ class JobSpec(BaseModel):
117117
fail_patterns: Sequence[str]
118118
"""regex patterns to match on to determine if the job has failed."""
119119

120+
@property
121+
def timeout_secs(self) -> int | None:
122+
"""Returns the timeout applied to the launched job, in seconds."""
123+
return None if self.timeout_mins is None else self.timeout_mins * 60
124+
120125

121126
class CompletedJobStatus(BaseModel):
122127
"""Job status."""

src/dvsim/launcher/local.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,7 @@ def _do_launch(self) -> None:
5959
self._log_file.flush()
6060

6161
if not self.job_spec.interactive:
62-
timeout_mins = self.job_spec.timeout_mins
63-
64-
self.timeout_secs = timeout_mins * 60 if timeout_mins else None
62+
self.timeout_secs = self.job_spec.timeout_secs
6563

6664
try:
6765
self._process = subprocess.Popen(

0 commit comments

Comments
 (0)