@@ -113,7 +113,7 @@ def mock_find_node_with_name_returns_fake_node(
113113 mocker : MockerFixture , fake_node : Node
114114) -> Iterator [mock .Mock ]:
115115 return mocker .patch (
116- "simcore_service_autoscaling.modules.auto_scaling_core .utils_docker.find_node_with_name" ,
116+ "simcore_service_autoscaling.modules.cluster_scaling._auto_scaling_core .utils_docker.find_node_with_name" ,
117117 autospec = True ,
118118 return_value = fake_node ,
119119 )
@@ -122,15 +122,15 @@ def mock_find_node_with_name_returns_fake_node(
122122@pytest .fixture
123123def mock_remove_nodes (mocker : MockerFixture ) -> mock .Mock :
124124 return mocker .patch (
125- "simcore_service_autoscaling.modules.auto_scaling_core .utils_docker.remove_nodes" ,
125+ "simcore_service_autoscaling.modules.cluster_scaling._auto_scaling_core .utils_docker.remove_nodes" ,
126126 autospec = True ,
127127 )
128128
129129
130130@pytest .fixture
131131def mock_compute_node_used_resources (mocker : MockerFixture ) -> mock .Mock :
132132 return mocker .patch (
133- "simcore_service_autoscaling.modules.auto_scaling_core .utils_docker.compute_node_used_resources" ,
133+ "simcore_service_autoscaling.modules.cluster_scaling._auto_scaling_core .utils_docker.compute_node_used_resources" ,
134134 autospec = True ,
135135 return_value = Resources .create_as_empty (),
136136 )
@@ -520,9 +520,9 @@ async def _test_cluster_scaling_up_and_down( # noqa: PLR0915
520520 all_instances = await ec2_client .describe_instances (Filters = instance_type_filters )
521521 assert not all_instances ["Reservations" ]
522522
523- assert scale_up_params . expected_num_instances == 1 , (
524- "This test is not made to work with more than 1 expected instance. so please adapt if needed"
525- )
523+ assert (
524+ scale_up_params . expected_num_instances == 1
525+ ), "This test is not made to work with more than 1 expected instance. so please adapt if needed"
526526
527527 # create the service(s)
528528 created_docker_services = await create_services_batch (scale_up_params )
@@ -860,7 +860,7 @@ async def _assert_wait_for_ec2_instances_running() -> list[InstanceTypeDef]:
860860 < app_settings .AUTOSCALING_EC2_INSTANCES .EC2_INSTANCES_TIME_BEFORE_TERMINATION
861861 )
862862 mocked_docker_remove_node = mocker .patch (
863- "simcore_service_autoscaling.modules.auto_scaling_core .utils_docker.remove_nodes" ,
863+ "simcore_service_autoscaling.modules.cluster_scaling._auto_scaling_core .utils_docker.remove_nodes" ,
864864 return_value = None ,
865865 autospec = True ,
866866 )
@@ -1281,9 +1281,7 @@ async def test_cluster_adapts_machines_on_the_fly( # noqa: PLR0915
12811281 assert (
12821282 scale_up_params1 .num_services
12831283 >= app_settings .AUTOSCALING_EC2_INSTANCES .EC2_INSTANCES_MAX_INSTANCES
1284- ), (
1285- "this test requires to run a first batch of more services than the maximum number of instances allowed"
1286- )
1284+ ), "this test requires to run a first batch of more services than the maximum number of instances allowed"
12871285 # we have nothing running now
12881286 all_instances = await ec2_client .describe_instances ()
12891287 assert not all_instances ["Reservations" ]
@@ -1380,7 +1378,7 @@ async def test_cluster_adapts_machines_on_the_fly( # noqa: PLR0915
13801378
13811379 # first call to auto_scale_cluster will mark 1 node as empty
13821380 with mock .patch (
1383- "simcore_service_autoscaling.modules.auto_scaling_core .utils_docker.set_node_found_empty" ,
1381+ "simcore_service_autoscaling.modules.cluster_scaling._auto_scaling_core .utils_docker.set_node_found_empty" ,
13841382 autospec = True ,
13851383 ) as mock_docker_set_node_found_empty :
13861384 await auto_scale_cluster (
@@ -1402,7 +1400,7 @@ async def test_cluster_adapts_machines_on_the_fly( # noqa: PLR0915
14021400
14031401 # now we mock the get_node_found_empty so the next call will actually drain the machine
14041402 with mock .patch (
1405- "simcore_service_autoscaling.modules.auto_scaling_core .utils_docker.get_node_empty_since" ,
1403+ "simcore_service_autoscaling.modules.cluster_scaling._auto_scaling_core .utils_docker.get_node_empty_since" ,
14061404 autospec = True ,
14071405 return_value = arrow .utcnow ().datetime
14081406 - 1.5
@@ -1437,7 +1435,7 @@ async def test_cluster_adapts_machines_on_the_fly( # noqa: PLR0915
14371435
14381436 # this will initiate termination now
14391437 with mock .patch (
1440- "simcore_service_autoscaling.modules.auto_scaling_core .utils_docker.get_node_last_readyness_update" ,
1438+ "simcore_service_autoscaling.modules.cluster_scaling._auto_scaling_core .utils_docker.get_node_last_readyness_update" ,
14411439 autospec = True ,
14421440 return_value = arrow .utcnow ().datetime
14431441 - 1.5
@@ -1477,14 +1475,14 @@ async def test_cluster_adapts_machines_on_the_fly( # noqa: PLR0915
14771475
14781476 # now this will terminate it and straight away start a new machine type
14791477 with mock .patch (
1480- "simcore_service_autoscaling.modules.auto_scaling_core .utils_docker.get_node_termination_started_since" ,
1478+ "simcore_service_autoscaling.modules.cluster_scaling._auto_scaling_core .utils_docker.get_node_termination_started_since" ,
14811479 autospec = True ,
14821480 return_value = arrow .utcnow ().datetime
14831481 - 1.5
14841482 * app_settings .AUTOSCALING_EC2_INSTANCES .EC2_INSTANCES_TIME_BEFORE_TERMINATION ,
14851483 ):
14861484 mocked_docker_remove_node = mocker .patch (
1487- "simcore_service_autoscaling.modules.auto_scaling_core .utils_docker.remove_nodes" ,
1485+ "simcore_service_autoscaling.modules.cluster_scaling._auto_scaling_core .utils_docker.remove_nodes" ,
14881486 return_value = None ,
14891487 autospec = True ,
14901488 )
@@ -1500,9 +1498,7 @@ async def test_cluster_adapts_machines_on_the_fly( # noqa: PLR0915
15001498 assert "Instances" in reservation1
15011499 assert len (reservation1 ["Instances" ]) == (
15021500 app_settings .AUTOSCALING_EC2_INSTANCES .EC2_INSTANCES_MAX_INSTANCES
1503- ), (
1504- f"expected { app_settings .AUTOSCALING_EC2_INSTANCES .EC2_INSTANCES_MAX_INSTANCES } EC2 instances, found { len (reservation1 ['Instances' ])} "
1505- )
1501+ ), f"expected { app_settings .AUTOSCALING_EC2_INSTANCES .EC2_INSTANCES_MAX_INSTANCES } EC2 instances, found { len (reservation1 ['Instances' ])} "
15061502 for instance in reservation1 ["Instances" ]:
15071503 assert "InstanceType" in instance
15081504 assert instance ["InstanceType" ] == scale_up_params1 .expected_instance_type
@@ -1516,9 +1512,9 @@ async def test_cluster_adapts_machines_on_the_fly( # noqa: PLR0915
15161512
15171513 reservation2 = all_instances ["Reservations" ][1 ]
15181514 assert "Instances" in reservation2
1519- assert len ( reservation2 [ "Instances" ]) == 1 , (
1520- f"expected 1 EC2 instances, found { len (reservation2 [' Instances' ]) } "
1521- )
1515+ assert (
1516+ len (reservation2 [" Instances" ]) == 1
1517+ ), f"expected 1 EC2 instances, found { len ( reservation2 [ 'Instances' ]) } "
15221518 for instance in reservation2 ["Instances" ]:
15231519 assert "InstanceType" in instance
15241520 assert instance ["InstanceType" ] == scale_up_params2 .expected_instance_type
@@ -2245,9 +2241,9 @@ async def test_warm_buffers_only_replace_hot_buffer_if_service_is_started_issue7
22452241 # BUG REPRODUCTION
22462242 #
22472243 # start a service that imposes same type as the hot buffer
2248- assert hot_buffer_instance_type == "t2.xlarge" , (
2249- "the test is hard-coded for this type and accordingly resource. If this changed then the resource shall be changed too "
2250- )
2244+ assert (
2245+ hot_buffer_instance_type == "t2.xlarge "
2246+ ), "the test is hard-coded for this type and accordingly resource. If this changed then the resource shall be changed too"
22512247 scale_up_params = _ScaleUpParams (
22522248 imposed_instance_type = hot_buffer_instance_type ,
22532249 service_resources = Resources (
0 commit comments