Skip to content

Commit 493b794

Browse files
committed
sonar
1 parent a2b6529 commit 493b794

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

packages/pytest-simcore/src/pytest_simcore/helpers/autoscaling.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def create_fake_association(
3939
):
4040
fake_node_to_instance_map = {}
4141

42-
async def _fake_node_creator(
42+
def _fake_node_creator(
4343
_nodes: list[Node], ec2_instances: list[EC2InstanceData]
4444
) -> tuple[list[AssociatedInstance], list[EC2InstanceData]]:
4545
def _create_fake_node_with_labels(instance: EC2InstanceData) -> Node:

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ async def _analyze_current_cluster(
9595
state_names=["stopped"],
9696
)
9797

98-
attached_ec2s, pending_ec2s = await associate_ec2_instances_with_nodes(
98+
attached_ec2s, pending_ec2s = associate_ec2_instances_with_nodes(
9999
docker_nodes, existing_ec2_instances
100100
)
101101

@@ -339,10 +339,10 @@ async def _sorted_allowed_instance_types(app: FastAPI) -> list[EC2InstanceType]:
339339
allowed_instance_type_names
340340
), "EC2_INSTANCES_ALLOWED_TYPES cannot be empty!"
341341

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

348348
def _as_selection(instance_type: EC2InstanceType) -> int:
@@ -949,7 +949,7 @@ async def _deactivate_empty_nodes(app: FastAPI, cluster: Cluster) -> Cluster:
949949
)
950950

951951

952-
async def _find_terminateable_instances(
952+
def _find_terminateable_instances(
953953
app: FastAPI, cluster: Cluster
954954
) -> list[AssociatedInstance]:
955955
app_settings: ApplicationSettings = app.state.settings
@@ -994,7 +994,7 @@ async def _try_scale_down_cluster(app: FastAPI, cluster: Cluster) -> Cluster:
994994
assert app_settings.AUTOSCALING_EC2_INSTANCES # nosec
995995
# instances found to be terminateable will now start the termination process.
996996
new_terminating_instances = []
997-
for instance in await _find_terminateable_instances(app, cluster):
997+
for instance in _find_terminateable_instances(app, cluster):
998998
assert instance.node.description is not None # nosec
999999
with (
10001000
log_context(
@@ -1076,9 +1076,9 @@ async def _notify_based_on_machine_type(
10761076
launch_time_to_tasks: dict[datetime.datetime, list] = collections.defaultdict(list)
10771077
now = datetime.datetime.now(datetime.UTC)
10781078
for instance in instances:
1079-
launch_time_to_tasks[
1080-
instance.ec2_instance.launch_time
1081-
] += instance.assigned_tasks
1079+
launch_time_to_tasks[instance.ec2_instance.launch_time] += (
1080+
instance.assigned_tasks
1081+
)
10821082

10831083
for launch_time, tasks in launch_time_to_tasks.items():
10841084
time_since_launch = now - launch_time

services/autoscaling/src/simcore_service_autoscaling/utils/cluster_scaling.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
_logger = logging.getLogger(__name__)
2424

2525

26-
async def associate_ec2_instances_with_nodes(
26+
def associate_ec2_instances_with_nodes(
2727
nodes: list[Node], ec2_instances: list[EC2InstanceData]
2828
) -> tuple[list[AssociatedInstance], list[EC2InstanceData]]:
2929
"""returns the associated and non-associated instances"""

services/autoscaling/tests/unit/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,8 +1075,8 @@ async def spied_cluster_analysis(mocker: MockerFixture) -> MockType:
10751075

10761076

10771077
@pytest.fixture
1078-
async def mocked_associate_ec2_instances_with_nodes(mocker: MockerFixture) -> mock.Mock:
1079-
async def _(
1078+
def mocked_associate_ec2_instances_with_nodes(mocker: MockerFixture) -> mock.Mock:
1079+
def _(
10801080
nodes: list[DockerNode], ec2_instances: list[EC2InstanceData]
10811081
) -> tuple[list[AssociatedInstance], list[EC2InstanceData]]:
10821082
return [], ec2_instances

services/autoscaling/tests/unit/test_utils_cluster_scaling.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ async def test_associate_ec2_instances_with_nodes_with_no_correspondence(
6969
(
7070
associated_instances,
7171
non_associated_instances,
72-
) = await associate_ec2_instances_with_nodes(nodes, ec2_instances)
72+
) = associate_ec2_instances_with_nodes(nodes, ec2_instances)
7373

7474
assert not associated_instances
7575
assert non_associated_instances
@@ -92,7 +92,7 @@ async def test_associate_ec2_instances_with_corresponding_nodes(
9292
(
9393
associated_instances,
9494
non_associated_instances,
95-
) = await associate_ec2_instances_with_nodes(nodes, ec2_instances)
95+
) = associate_ec2_instances_with_nodes(nodes, ec2_instances)
9696

9797
assert associated_instances
9898
assert not non_associated_instances

0 commit comments

Comments
 (0)