Skip to content

Commit

Permalink
Merge pull request #186 from openforcefield/compute-n_retries
Browse files Browse the repository at this point in the history
Added `n_retries` usage for `SynchronousComputeService`
  • Loading branch information
dotsdl authored Oct 6, 2023
2 parents 9a20f20 + 12f2759 commit b5a4e58
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions alchemiscale/compute/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def __init__(
scratch_basedir: os.PathLike,
keep_shared: bool = False,
keep_scratch: bool = False,
n_retries: int = 3,
sleep_interval: int = 30,
heartbeat_interval: int = 300,
scopes: Optional[List[Scope]] = None,
Expand Down Expand Up @@ -118,6 +119,8 @@ def __init__(
keep_scratch
If True, don't remove scratch directories for `ProtocolUnit`s after
completion.
n_retries
Number of times to attempt a given Task on failure.
sleep_interval
Time in seconds to sleep if no Tasks claimed from compute API.
heartbeat_interval
Expand Down Expand Up @@ -177,6 +180,8 @@ def __init__(
self.scratch_basedir.mkdir(exist_ok=True)
self.keep_scratch = keep_scratch

self.n_retries = n_retries

self.scheduler = sched.scheduler(time.monotonic, time.sleep)

self.compute_service_id = ComputeServiceID(f"{self.name}-{uuid4()}")
Expand Down Expand Up @@ -336,6 +341,7 @@ def execute(self, task: ScopedKey) -> ScopedKey:
scratch_basedir=scratch,
keep_scratch=self.keep_scratch,
raise_error=False,
n_retries=self.n_retries,
)
finally:
if not self.keep_shared:
Expand Down
3 changes: 3 additions & 0 deletions devtools/configs/synchronous-compute-settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ init:
# completion.
keep_scratch: False

# Number of times to attempt a given Task on failure
n_retries: 3

# Time in seconds to sleep if no Tasks claimed from compute API.
sleep_interval: 30

Expand Down

0 comments on commit b5a4e58

Please sign in to comment.