Skip to content

Commit 478ab00

Browse files
committed
renamed classes
1 parent d52471c commit 478ab00

File tree

9 files changed

+78
-78
lines changed

9 files changed

+78
-78
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def _scheduler_auth(app: FastAPI) -> ClusterAuthentication:
4141
return app_settings.AUTOSCALING_DASK.DASK_SCHEDULER_AUTH
4242

4343

44-
class ComputationalAutoscaling:
44+
class ComputationalAutoscalingProvider:
4545
async def get_monitored_nodes(self, app: FastAPI) -> list[Node]:
4646
return await utils_docker.get_worker_nodes(get_docker_client(app))
4747

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from ..docker import get_docker_client
1111

1212

13-
class DynamicAutoscaling:
13+
class DynamicAutoscalingProvider:
1414
async def get_monitored_nodes(self, app: FastAPI) -> list[Node]:
1515
app_settings = get_application_settings(app)
1616
assert app_settings.AUTOSCALING_NODES_MONITORING # nosec

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
from ...utils.redis import create_lock_key_and_value
1212
from ..redis import get_redis_client
1313
from ._auto_scaling_core import auto_scale_cluster
14-
from ._provider_computational import ComputationalAutoscaling
15-
from ._provider_dynamic import DynamicAutoscaling
14+
from ._provider_computational import ComputationalAutoscalingProvider
15+
from ._provider_dynamic import DynamicAutoscalingProvider
1616

1717
_TASK_NAME: Final[str] = "Autoscaling EC2 instances"
1818

@@ -33,9 +33,9 @@ async def _startup() -> None:
3333
task_name=_TASK_NAME,
3434
app=app,
3535
auto_scaling_mode=(
36-
DynamicAutoscaling()
36+
DynamicAutoscalingProvider()
3737
if app_settings.AUTOSCALING_NODES_MONITORING is not None
38-
else ComputationalAutoscaling()
38+
else ComputationalAutoscalingProvider()
3939
),
4040
)
4141

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from ...utils.redis import create_lock_key_and_value
1212
from ..redis import get_redis_client
1313
from ._buffer_machines_pool_core import monitor_buffer_machines
14-
from ._provider_dynamic import DynamicAutoscaling
14+
from ._provider_dynamic import DynamicAutoscalingProvider
1515

1616
_TASK_NAME_BUFFER: Final[str] = "Autoscaling Buffer Machines Pool"
1717

@@ -35,7 +35,7 @@ async def _startup() -> None:
3535
interval=app_settings.AUTOSCALING_POLL_INTERVAL,
3636
task_name=_TASK_NAME_BUFFER,
3737
app=app,
38-
auto_scaling_mode=(DynamicAutoscaling()),
38+
auto_scaling_mode=(DynamicAutoscalingProvider()),
3939
)
4040

4141
return _startup

services/autoscaling/tests/unit/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
)
8181
from simcore_service_autoscaling.modules.cluster_scaling import _auto_scaling_core
8282
from simcore_service_autoscaling.modules.cluster_scaling._provider_dynamic import (
83-
DynamicAutoscaling,
83+
DynamicAutoscalingProvider,
8484
)
8585
from simcore_service_autoscaling.modules.docker import AutoscalingDocker
8686
from simcore_service_autoscaling.modules.ec2 import SimcoreEC2API
@@ -1185,7 +1185,7 @@ async def _do(
11851185
resource_tags: list[TagTypeDef] = [
11861186
{"Key": tag_key, "Value": tag_value}
11871187
for tag_key, tag_value in get_deactivated_buffer_ec2_tags(
1188-
DynamicAutoscaling().get_ec2_tags(initialized_app)
1188+
DynamicAutoscalingProvider().get_ec2_tags(initialized_app)
11891189
).items()
11901190
]
11911191
if pre_pull_images is not None and instance_state_name == "stopped":

services/autoscaling/tests/unit/test_modules_auto_scaling_computational.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
auto_scale_cluster,
5151
)
5252
from simcore_service_autoscaling.modules.cluster_scaling._provider_computational import (
53-
ComputationalAutoscaling,
53+
ComputationalAutoscalingProvider,
5454
)
5555
from simcore_service_autoscaling.modules.dask import DaskTaskResources
5656
from simcore_service_autoscaling.modules.docker import get_docker_client
@@ -333,7 +333,7 @@ async def test_cluster_scaling_with_no_tasks_does_nothing(
333333
dask_spec_local_cluster: distributed.SpecCluster,
334334
):
335335
await auto_scale_cluster(
336-
app=initialized_app, auto_scaling_mode=ComputationalAutoscaling()
336+
app=initialized_app, auto_scaling_mode=ComputationalAutoscalingProvider()
337337
)
338338
mock_launch_instances.assert_not_called()
339339
mock_terminate_instances.assert_not_called()
@@ -371,7 +371,7 @@ async def test_cluster_scaling_with_disabled_ssm_does_not_block_autoscaling(
371371
dask_spec_local_cluster: distributed.SpecCluster,
372372
):
373373
await auto_scale_cluster(
374-
app=initialized_app, auto_scaling_mode=ComputationalAutoscaling()
374+
app=initialized_app, auto_scaling_mode=ComputationalAutoscalingProvider()
375375
)
376376
mock_launch_instances.assert_not_called()
377377
mock_terminate_instances.assert_not_called()
@@ -412,7 +412,7 @@ async def test_cluster_scaling_with_task_with_too_much_resources_starts_nothing(
412412
assert dask_future
413413

414414
await auto_scale_cluster(
415-
app=initialized_app, auto_scaling_mode=ComputationalAutoscaling()
415+
app=initialized_app, auto_scaling_mode=ComputationalAutoscalingProvider()
416416
)
417417
mock_launch_instances.assert_not_called()
418418
mock_terminate_instances.assert_not_called()
@@ -504,7 +504,7 @@ async def test_cluster_scaling_up_and_down( # noqa: PLR0915
504504
assert dask_futures
505505
# this should trigger a scaling up as we have no nodes
506506
await auto_scale_cluster(
507-
app=initialized_app, auto_scaling_mode=ComputationalAutoscaling()
507+
app=initialized_app, auto_scaling_mode=ComputationalAutoscalingProvider()
508508
)
509509

510510
# check the instance was started and we have exactly 1
@@ -538,7 +538,7 @@ async def test_cluster_scaling_up_and_down( # noqa: PLR0915
538538

539539
# 2. running this again should not scale again, but tag the node and make it available
540540
await auto_scale_cluster(
541-
app=initialized_app, auto_scaling_mode=ComputationalAutoscaling()
541+
app=initialized_app, auto_scaling_mode=ComputationalAutoscalingProvider()
542542
)
543543
mock_dask_get_worker_has_results_in_memory.assert_called_once()
544544
mock_dask_get_worker_has_results_in_memory.reset_mock()
@@ -636,7 +636,7 @@ async def test_cluster_scaling_up_and_down( # noqa: PLR0915
636636
assert fake_attached_node.description
637637
fake_attached_node.description.hostname = internal_dns_name
638638

639-
auto_scaling_mode = ComputationalAutoscaling()
639+
auto_scaling_mode = ComputationalAutoscalingProvider()
640640
mocker.patch.object(
641641
auto_scaling_mode,
642642
"get_monitored_nodes",
@@ -880,7 +880,7 @@ async def test_cluster_does_not_scale_up_if_defined_instance_is_not_allowed(
880880

881881
# this should trigger a scaling up as we have no nodes
882882
await auto_scale_cluster(
883-
app=initialized_app, auto_scaling_mode=ComputationalAutoscaling()
883+
app=initialized_app, auto_scaling_mode=ComputationalAutoscalingProvider()
884884
)
885885

886886
# nothing runs
@@ -931,7 +931,7 @@ async def test_cluster_does_not_scale_up_if_defined_instance_is_not_fitting_reso
931931

932932
# this should trigger a scaling up as we have no nodes
933933
await auto_scale_cluster(
934-
app=initialized_app, auto_scaling_mode=ComputationalAutoscaling()
934+
app=initialized_app, auto_scaling_mode=ComputationalAutoscalingProvider()
935935
)
936936

937937
# nothing runs
@@ -998,7 +998,7 @@ async def test_cluster_scaling_up_starts_multiple_instances(
998998

999999
# run the code
10001000
await auto_scale_cluster(
1001-
app=initialized_app, auto_scaling_mode=ComputationalAutoscaling()
1001+
app=initialized_app, auto_scaling_mode=ComputationalAutoscalingProvider()
10021002
)
10031003

10041004
# check the instances were started
@@ -1090,7 +1090,7 @@ async def test_cluster_scaling_up_more_than_allowed_max_starts_max_instances_and
10901090

10911091
# this should trigger a scaling up as we have no nodes
10921092
await auto_scale_cluster(
1093-
app=initialized_app, auto_scaling_mode=ComputationalAutoscaling()
1093+
app=initialized_app, auto_scaling_mode=ComputationalAutoscalingProvider()
10941094
)
10951095
await assert_autoscaled_computational_ec2_instances(
10961096
ec2_client,
@@ -1122,7 +1122,7 @@ async def test_cluster_scaling_up_more_than_allowed_max_starts_max_instances_and
11221122
num_useless_calls = 10
11231123
for _ in range(num_useless_calls):
11241124
await auto_scale_cluster(
1125-
app=initialized_app, auto_scaling_mode=ComputationalAutoscaling()
1125+
app=initialized_app, auto_scaling_mode=ComputationalAutoscalingProvider()
11261126
)
11271127
await assert_autoscaled_computational_ec2_instances(
11281128
ec2_client,
@@ -1191,7 +1191,7 @@ async def test_cluster_scaling_up_more_than_allowed_with_multiple_types_max_star
11911191

11921192
# this should trigger a scaling up as we have no nodes
11931193
await auto_scale_cluster(
1194-
app=initialized_app, auto_scaling_mode=ComputationalAutoscaling()
1194+
app=initialized_app, auto_scaling_mode=ComputationalAutoscalingProvider()
11951195
)
11961196

11971197
# one of each type is created with some that will have 2 instances
@@ -1235,7 +1235,7 @@ async def test_cluster_scaling_up_more_than_allowed_with_multiple_types_max_star
12351235
num_useless_calls = 10
12361236
for _ in range(num_useless_calls):
12371237
await auto_scale_cluster(
1238-
app=initialized_app, auto_scaling_mode=ComputationalAutoscaling()
1238+
app=initialized_app, auto_scaling_mode=ComputationalAutoscalingProvider()
12391239
)
12401240
all_instances = await ec2_client.describe_instances()
12411241
assert len(all_instances["Reservations"]) == len(
@@ -1301,7 +1301,7 @@ async def test_long_pending_ec2_is_detected_as_broken_terminated_and_restarted(
13011301

13021302
# this should trigger a scaling up as we have no nodes
13031303
await auto_scale_cluster(
1304-
app=initialized_app, auto_scaling_mode=ComputationalAutoscaling()
1304+
app=initialized_app, auto_scaling_mode=ComputationalAutoscalingProvider()
13051305
)
13061306

13071307
# check the instance was started and we have exactly 1
@@ -1345,7 +1345,7 @@ async def test_long_pending_ec2_is_detected_as_broken_terminated_and_restarted(
13451345
# 2. running again several times the autoscaler, the node does not join
13461346
for i in range(7):
13471347
await auto_scale_cluster(
1348-
app=initialized_app, auto_scaling_mode=ComputationalAutoscaling()
1348+
app=initialized_app, auto_scaling_mode=ComputationalAutoscalingProvider()
13491349
)
13501350
# there should be no scaling up, since there is already a pending instance
13511351
instances = await assert_autoscaled_computational_ec2_instances(
@@ -1389,7 +1389,7 @@ async def test_long_pending_ec2_is_detected_as_broken_terminated_and_restarted(
13891389
)
13901390
# scaling now will terminate the broken ec2 that did not connect, and directly create a replacement
13911391
await auto_scale_cluster(
1392-
app=initialized_app, auto_scaling_mode=ComputationalAutoscaling()
1392+
app=initialized_app, auto_scaling_mode=ComputationalAutoscalingProvider()
13931393
)
13941394
# we have therefore 2 reservations, first instance is terminated and a second one started
13951395
all_instances = await ec2_client.describe_instances()
@@ -1492,7 +1492,7 @@ async def test_cluster_adapts_machines_on_the_fly(
14921492

14931493
# it will only scale once and do nothing else
14941494
await auto_scale_cluster(
1495-
app=initialized_app, auto_scaling_mode=ComputationalAutoscaling()
1495+
app=initialized_app, auto_scaling_mode=ComputationalAutoscalingProvider()
14961496
)
14971497
await assert_autoscaled_computational_ec2_instances(
14981498
ec2_client,
@@ -1519,7 +1519,7 @@ async def test_cluster_adapts_machines_on_the_fly(
15191519
#
15201520
# 2. now the machines are associated
15211521
await auto_scale_cluster(
1522-
app=initialized_app, auto_scaling_mode=ComputationalAutoscaling()
1522+
app=initialized_app, auto_scaling_mode=ComputationalAutoscalingProvider()
15231523
)
15241524
analyzed_cluster = assert_cluster_state(
15251525
spied_cluster_analysis,
@@ -1542,7 +1542,7 @@ async def test_cluster_adapts_machines_on_the_fly(
15421542
# scaling will do nothing since we have hit the maximum number of machines
15431543
for _ in range(3):
15441544
await auto_scale_cluster(
1545-
app=initialized_app, auto_scaling_mode=ComputationalAutoscaling()
1545+
app=initialized_app, auto_scaling_mode=ComputationalAutoscalingProvider()
15461546
)
15471547
await assert_autoscaled_computational_ec2_instances(
15481548
ec2_client,
@@ -1576,7 +1576,7 @@ async def test_cluster_adapts_machines_on_the_fly(
15761576
autospec=True,
15771577
) as mock_docker_set_node_found_empty:
15781578
await auto_scale_cluster(
1579-
app=initialized_app, auto_scaling_mode=ComputationalAutoscaling()
1579+
app=initialized_app, auto_scaling_mode=ComputationalAutoscalingProvider()
15801580
)
15811581
analyzed_cluster = assert_cluster_state(
15821582
spied_cluster_analysis,
@@ -1601,7 +1601,7 @@ async def test_cluster_adapts_machines_on_the_fly(
16011601
* app_settings.AUTOSCALING_EC2_INSTANCES.EC2_INSTANCES_TIME_BEFORE_DRAINING,
16021602
) as mocked_get_node_empty_since:
16031603
await auto_scale_cluster(
1604-
app=initialized_app, auto_scaling_mode=ComputationalAutoscaling()
1604+
app=initialized_app, auto_scaling_mode=ComputationalAutoscalingProvider()
16051605
)
16061606
mocked_get_node_empty_since.assert_called_once()
16071607
analyzed_cluster = assert_cluster_state(
@@ -1617,7 +1617,7 @@ async def test_cluster_adapts_machines_on_the_fly(
16171617
create_fake_node, drained_machine_instance_id, None
16181618
)
16191619
await auto_scale_cluster(
1620-
app=initialized_app, auto_scaling_mode=ComputationalAutoscaling()
1620+
app=initialized_app, auto_scaling_mode=ComputationalAutoscalingProvider()
16211621
)
16221622
analyzed_cluster = assert_cluster_state(
16231623
spied_cluster_analysis,
@@ -1637,7 +1637,7 @@ async def test_cluster_adapts_machines_on_the_fly(
16371637
):
16381638
mock_docker_tag_node.reset_mock()
16391639
await auto_scale_cluster(
1640-
app=initialized_app, auto_scaling_mode=ComputationalAutoscaling()
1640+
app=initialized_app, auto_scaling_mode=ComputationalAutoscalingProvider()
16411641
)
16421642
analyzed_cluster = assert_cluster_state(
16431643
spied_cluster_analysis,
@@ -1656,7 +1656,7 @@ async def test_cluster_adapts_machines_on_the_fly(
16561656
create_fake_node, drained_machine_instance_id, drained_machine_instance_id
16571657
)
16581658
await auto_scale_cluster(
1659-
app=initialized_app, auto_scaling_mode=ComputationalAutoscaling()
1659+
app=initialized_app, auto_scaling_mode=ComputationalAutoscalingProvider()
16601660
)
16611661
analyzed_cluster = assert_cluster_state(
16621662
spied_cluster_analysis,
@@ -1681,7 +1681,7 @@ async def test_cluster_adapts_machines_on_the_fly(
16811681
autospec=True,
16821682
)
16831683
await auto_scale_cluster(
1684-
app=initialized_app, auto_scaling_mode=ComputationalAutoscaling()
1684+
app=initialized_app, auto_scaling_mode=ComputationalAutoscalingProvider()
16851685
)
16861686
mocked_docker_remove_node.assert_called_once()
16871687

0 commit comments

Comments
 (0)