Skip to content

Commit 823dcf3

Browse files
committed
Black format and address quick fixes from review
1 parent aa6b192 commit 823dcf3

6 files changed

Lines changed: 40 additions & 43 deletions

File tree

alchemiscale/compute/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ def computemanager_get_instruction(
468468
settings: ComputeAPISettings = Depends(get_base_api_settings),
469469
token: TokenData = Depends(get_token_data_depends),
470470
):
471-
scopes = scopes or [Scope.from_str("*-*-*")]
471+
scopes = scopes or [Scope.from_str()]
472472
scopes_reduced = minimize_scope_space(scopes)
473473
query_scopes = []
474474
for scope in scopes_reduced:

alchemiscale/compute/manager.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,10 @@ def _deregister(self):
6363

6464
def start(self, max_cycles: int | None = None):
6565
self._register()
66+
self._stop = False
6667
try:
6768
count = 0
68-
while True:
69+
while not self._stop:
6970
self.cycle()
7071
count += 1
7172
if max_cycles and count >= max_cycles:
@@ -113,13 +114,10 @@ def cycle(self):
113114
case ComputeManagerInstruction.SHUTDOWN:
114115
shutdown_message = data["message"]
115116
self.logger.info(f'Received shutdown message: "{shutdown_message}"')
117+
self._stop = True
116118
return
117119
self.client.update_status(
118120
self.compute_manager_id,
119121
ComputeManagerStatus.OK,
120122
saturation=total_services / self.settings.max_compute_services,
121123
)
122-
123-
@abstractmethod
124-
def create_compute_service(self):
125-
raise NotImplementedError

alchemiscale/compute/settings.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ class ComputeManagerSettings(BaseModel):
146146
description="Maximum number of compute services the manager is allowed to have running at a time.",
147147
)
148148
sleep_interval: int = Field(
149-
1800, description="Time in seconds to sleep before requesting another instruction."
149+
1800,
150+
description="Time in seconds to sleep before requesting another instruction.",
150151
)
151152
loglevel: str = Field(
152153
"WARN",

alchemiscale/models.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
"""
66

77
from typing import Any
8-
from enum import StrEnum
98
from pydantic import BaseModel, field_validator, model_validator, ConfigDict
109
from gufe.tokenization import GufeKey
1110
from re import fullmatch

alchemiscale/storage/models.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,8 @@ class ComputeManagerStatus(StrEnum):
7272

7373
class ComputeManagerID(str):
7474

75-
def __init__(self, value):
76-
super().__init__()
77-
75+
def __init__(self, _value):
76+
# don't need to process _value, handled by str.__new__
7877
parts = self.split("-")
7978

8079
if len(parts) != 6:
@@ -140,7 +139,7 @@ def to_dict(self):
140139

141140
@classmethod
142141
def from_dict(cls, dct):
143-
return cls(**dct_)
142+
return cls(**dct)
144143

145144
def to_compute_manager_id(self):
146145
return ComputeManagerID("-".join([self.manager_name, self.uuid]))

alchemiscale/storage/statestore.py

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1583,37 +1583,37 @@ def get_computemanager_instruction(
15831583
) -> tuple[ComputeManagerInstruction, dict]:
15841584
"""Return an instruction for a compute manager based on the contents of the statestore.
15851585
1586-
This method returns one of three instructions along with supporting data:
1587-
1588-
1. "OK" with a list of ComputeServiceIDs and the number of available tasks
1589-
2. "SKIP" with a list of ComputeServiceIDs
1590-
3. "SHUTDOWN" with an error message
1591-
1592-
Parameters
1593-
----------
1594-
compute_manager_id
1595-
The compute manager ID string containing the manager_name
1596-
and the UUID.
1597-
1598-
forgive_time
1599-
The time at which a failure from a compute service is
1600-
considered forgiven.
1601-
1602-
max_failures
1603-
The number of failures a compute service is allowed to
1604-
have (before the forgive time) before it is no longer
1605-
allowed to claim a task. If any managed compute services
1606-
have failues that exceed this value, the returned
1607-
instruction will be SKIP.
1608-
1609-
scopes
1610-
The scopes to consider when determining available tasks.
1611-
1612-
Returns
1613-
-------
1614-
A tuple with whose first value is the instruction enumeration
1615-
and whose second value is data associated with that
1616-
instruction.
1586+
This method returns one of three instructions along with supporting data:
1587+
1588+
1. "OK" with a list of ComputeServiceIDs and the number of available tasks
1589+
2. "SKIP" with a list of ComputeServiceIDs
1590+
3. "SHUTDOWN" with an error message
1591+
1592+
Parameters
1593+
----------
1594+
compute_manager_id
1595+
The compute manager ID string containing the manager_name
1596+
and the UUID.
1597+
1598+
forgive_time
1599+
The time at which a failure from a compute service is
1600+
considered forgiven.
1601+
1602+
max_failures
1603+
The number of failures a compute service is allowed to
1604+
have (before the forgive time) before it is no longer
1605+
allowed to claim a task. If any managed compute services
1606+
have failues that exceed this value, the returned
1607+
instruction will be SKIP.
1608+
1609+
scopes
1610+
The scopes to consider when determining available tasks.
1611+
1612+
Returns
1613+
-------
1614+
A tuple with whose first value is the instruction enumeration
1615+
and whose second value is data associated with that
1616+
instruction.
16171617
16181618
"""
16191619

0 commit comments

Comments
 (0)