Skip to content

Commit 85629f0

Browse files
committed
rename class
1 parent a7b60d7 commit 85629f0

File tree

3 files changed

+24
-24
lines changed

3 files changed

+24
-24
lines changed

services/autoscaling/src/simcore_service_autoscaling/modules/cluster_scaling/_auto_scaling_core.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,14 @@
6161
from ..ec2 import get_ec2_client
6262
from ..instrumentation import get_instrumentation, has_instrumentation
6363
from ..ssm import get_ssm_client
64-
from .auto_scaling_mode_base import BaseAutoscaling
64+
from .auto_scaling_mode_base import AutoscalingProvider
6565

6666
_logger = logging.getLogger(__name__)
6767

6868

6969
async def _analyze_current_cluster(
7070
app: FastAPI,
71-
auto_scaling_mode: BaseAutoscaling,
71+
auto_scaling_mode: AutoscalingProvider,
7272
allowed_instance_types: list[EC2InstanceType],
7373
) -> Cluster:
7474
app_settings = get_application_settings(app)
@@ -275,7 +275,7 @@ async def _make_pending_buffer_ec2s_join_cluster(
275275
async def _try_attach_pending_ec2s(
276276
app: FastAPI,
277277
cluster: Cluster,
278-
auto_scaling_mode: BaseAutoscaling,
278+
auto_scaling_mode: AutoscalingProvider,
279279
allowed_instance_types: list[EC2InstanceType],
280280
) -> Cluster:
281281
"""label the drained instances that connected to the swarm which are missing the monitoring labels"""
@@ -340,10 +340,10 @@ async def _sorted_allowed_instance_types(app: FastAPI) -> list[EC2InstanceType]:
340340
allowed_instance_type_names
341341
), "EC2_INSTANCES_ALLOWED_TYPES cannot be empty!"
342342

343-
allowed_instance_types: list[
344-
EC2InstanceType
345-
] = await ec2_client.get_ec2_instance_capabilities(
346-
cast(set[InstanceTypeType], set(allowed_instance_type_names))
343+
allowed_instance_types: list[EC2InstanceType] = (
344+
await ec2_client.get_ec2_instance_capabilities(
345+
cast(set[InstanceTypeType], set(allowed_instance_type_names))
346+
)
347347
)
348348

349349
def _as_selection(instance_type: EC2InstanceType) -> int:
@@ -421,7 +421,7 @@ async def _activate_drained_nodes(
421421

422422

423423
async def _start_warm_buffer_instances(
424-
app: FastAPI, cluster: Cluster, auto_scaling_mode: BaseAutoscaling
424+
app: FastAPI, cluster: Cluster, auto_scaling_mode: AutoscalingProvider
425425
) -> Cluster:
426426
"""starts warm buffer if there are assigned tasks, or if a hot buffer of the same type is needed"""
427427

@@ -544,7 +544,7 @@ async def _assign_tasks_to_current_cluster(
544544
app: FastAPI,
545545
tasks: list,
546546
cluster: Cluster,
547-
auto_scaling_mode: BaseAutoscaling,
547+
auto_scaling_mode: AutoscalingProvider,
548548
) -> tuple[list, Cluster]:
549549
"""
550550
Evaluates whether a task can be executed on any instance within the cluster. If the task's resource requirements are met, the task is *denoted* as assigned to the cluster.
@@ -602,7 +602,7 @@ async def _find_needed_instances(
602602
unassigned_tasks: list,
603603
available_ec2_types: list[EC2InstanceType],
604604
cluster: Cluster,
605-
auto_scaling_mode: BaseAutoscaling,
605+
auto_scaling_mode: AutoscalingProvider,
606606
) -> dict[EC2InstanceType, int]:
607607
# 1. check first the pending task needs
608608
needed_new_instance_types_for_tasks: list[AssignedTasksToInstanceType] = []
@@ -775,7 +775,7 @@ async def _launch_instances(
775775
app: FastAPI,
776776
needed_instances: dict[EC2InstanceType, int],
777777
tasks: list,
778-
auto_scaling_mode: BaseAutoscaling,
778+
auto_scaling_mode: AutoscalingProvider,
779779
) -> list[EC2InstanceData]:
780780
ec2_client = get_ec2_client(app)
781781
app_settings = get_application_settings(app)
@@ -1075,9 +1075,9 @@ async def _notify_based_on_machine_type(
10751075
launch_time_to_tasks: dict[datetime.datetime, list] = collections.defaultdict(list)
10761076
now = datetime.datetime.now(datetime.UTC)
10771077
for instance in instances:
1078-
launch_time_to_tasks[instance.ec2_instance.launch_time] += (
1079-
instance.assigned_tasks
1080-
)
1078+
launch_time_to_tasks[
1079+
instance.ec2_instance.launch_time
1080+
] += instance.assigned_tasks
10811081

10821082
for launch_time, tasks in launch_time_to_tasks.items():
10831083
time_since_launch = now - launch_time
@@ -1147,7 +1147,7 @@ async def _drain_retired_nodes(
11471147
async def _scale_down_unused_cluster_instances(
11481148
app: FastAPI,
11491149
cluster: Cluster,
1150-
auto_scaling_mode: BaseAutoscaling,
1150+
auto_scaling_mode: AutoscalingProvider,
11511151
) -> Cluster:
11521152
await auto_scaling_mode.try_retire_nodes(app)
11531153
cluster = await _deactivate_empty_nodes(app, cluster)
@@ -1157,7 +1157,7 @@ async def _scale_down_unused_cluster_instances(
11571157
async def _scale_up_cluster(
11581158
app: FastAPI,
11591159
cluster: Cluster,
1160-
auto_scaling_mode: BaseAutoscaling,
1160+
auto_scaling_mode: AutoscalingProvider,
11611161
allowed_instance_types: list[EC2InstanceType],
11621162
unassigned_tasks: list,
11631163
) -> Cluster:
@@ -1209,7 +1209,7 @@ async def _scale_up_cluster(
12091209
async def _autoscale_cluster(
12101210
app: FastAPI,
12111211
cluster: Cluster,
1212-
auto_scaling_mode: BaseAutoscaling,
1212+
auto_scaling_mode: AutoscalingProvider,
12131213
allowed_instance_types: list[EC2InstanceType],
12141214
) -> Cluster:
12151215
# 1. check if we have pending tasks
@@ -1242,7 +1242,7 @@ async def _autoscale_cluster(
12421242

12431243

12441244
async def _notify_autoscaling_status(
1245-
app: FastAPI, cluster: Cluster, auto_scaling_mode: BaseAutoscaling
1245+
app: FastAPI, cluster: Cluster, auto_scaling_mode: AutoscalingProvider
12461246
) -> None:
12471247
monitored_instances = list(
12481248
itertools.chain(
@@ -1271,7 +1271,7 @@ async def _notify_autoscaling_status(
12711271

12721272

12731273
async def auto_scale_cluster(
1274-
*, app: FastAPI, auto_scaling_mode: BaseAutoscaling
1274+
*, app: FastAPI, auto_scaling_mode: AutoscalingProvider
12751275
) -> None:
12761276
"""Check that there are no pending tasks requiring additional resources in the cluster (docker swarm)
12771277
If there are such tasks, this method will allocate new machines in AWS to cope with

services/autoscaling/src/simcore_service_autoscaling/modules/cluster_scaling/_buffer_machines_pool_core.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
from ..ec2 import get_ec2_client
5353
from ..instrumentation import get_instrumentation, has_instrumentation
5454
from ..ssm import get_ssm_client
55-
from .auto_scaling_mode_base import BaseAutoscaling
55+
from .auto_scaling_mode_base import AutoscalingProvider
5656

5757
_logger = logging.getLogger(__name__)
5858

@@ -111,7 +111,7 @@ async def _analyze_running_instance_state(
111111

112112

113113
async def _analyse_current_state(
114-
app: FastAPI, *, auto_scaling_mode: BaseAutoscaling
114+
app: FastAPI, *, auto_scaling_mode: AutoscalingProvider
115115
) -> BufferPoolManager:
116116
ec2_client = get_ec2_client(app)
117117
app_settings = get_application_settings(app)
@@ -229,7 +229,7 @@ async def _add_remove_buffer_instances(
229229
app: FastAPI,
230230
buffers_manager: BufferPoolManager,
231231
*,
232-
auto_scaling_mode: BaseAutoscaling,
232+
auto_scaling_mode: AutoscalingProvider,
233233
) -> BufferPoolManager:
234234
ec2_client = get_ec2_client(app)
235235
app_settings = get_application_settings(app)
@@ -399,7 +399,7 @@ async def _handle_image_pre_pulling(
399399

400400

401401
async def monitor_buffer_machines(
402-
app: FastAPI, *, auto_scaling_mode: BaseAutoscaling
402+
app: FastAPI, *, auto_scaling_mode: AutoscalingProvider
403403
) -> None:
404404
"""Buffer machine creation works like so:
405405
1. a EC2 is created with an EBS attached volume wO auto prepulling and wO auto connect to swarm

services/autoscaling/src/simcore_service_autoscaling/modules/cluster_scaling/auto_scaling_mode_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from ...models import AssociatedInstance
1010

1111

12-
class BaseAutoscaling(Protocol):
12+
class AutoscalingProvider(Protocol):
1313
async def get_monitored_nodes(self, app: FastAPI) -> list[DockerNode]: ...
1414

1515
def get_ec2_tags(self, app: FastAPI) -> EC2Tags: ...

0 commit comments

Comments
 (0)