@@ -43,21 +43,25 @@ def _scheduler_auth(app: FastAPI) -> ClusterAuthentication:
4343
4444class ComputationalAutoscalingProvider :
4545 async def get_monitored_nodes (self , app : FastAPI ) -> list [Node ]:
46+ assert self # nosec
4647 return await utils_docker .get_worker_nodes (get_docker_client (app ))
4748
4849 def get_ec2_tags (self , app : FastAPI ) -> EC2Tags :
50+ assert self # nosec
4951 app_settings = get_application_settings (app )
5052 return utils_ec2 .get_ec2_tags_computational (app_settings )
5153
5254 def get_new_node_docker_tags (
5355 self , app : FastAPI , ec2_instance_data : EC2InstanceData
5456 ) -> dict [DockerLabelKey , str ]:
57+ assert self # nosec
5558 assert app # nosec
5659 return {
5760 DOCKER_TASK_EC2_INSTANCE_TYPE_PLACEMENT_CONSTRAINT_KEY : ec2_instance_data .type
5861 }
5962
6063 async def list_unrunnable_tasks (self , app : FastAPI ) -> list [DaskTask ]:
64+ assert self # nosec
6165 try :
6266 unrunnable_tasks = await dask .list_unrunnable_tasks (
6367 _scheduler_url (app ), _scheduler_auth (app )
@@ -83,17 +87,20 @@ async def list_unrunnable_tasks(self, app: FastAPI) -> list[DaskTask]:
8387 return []
8488
8589 def get_task_required_resources (self , task ) -> Resources :
90+ assert self # nosec
8691 return utils .resources_from_dask_task (task )
8792
8893 async def get_task_defined_instance (
8994 self , app : FastAPI , task
9095 ) -> InstanceTypeType | None :
96+ assert self # nosec
9197 assert app # nosec
9298 return cast (InstanceTypeType | None , utils .get_task_instance_restriction (task ))
9399
94100 async def compute_node_used_resources (
95101 self , app : FastAPI , instance : AssociatedInstance
96102 ) -> Resources :
103+ assert self # nosec
97104 try :
98105 resource = await dask .get_worker_used_resources (
99106 _scheduler_url (app ), _scheduler_auth (app ), instance .ec2_instance
@@ -124,6 +131,7 @@ async def compute_node_used_resources(
124131 async def compute_cluster_used_resources (
125132 self , app : FastAPI , instances : list [AssociatedInstance ]
126133 ) -> Resources :
134+ assert self # nosec
127135 list_of_used_resources : list [Resources ] = await logged_gather (
128136 * (self .compute_node_used_resources (app , i ) for i in instances )
129137 )
@@ -135,6 +143,7 @@ async def compute_cluster_used_resources(
135143 async def compute_cluster_total_resources (
136144 self , app : FastAPI , instances : list [AssociatedInstance ]
137145 ) -> Resources :
146+ assert self # nosec
138147 try :
139148 return await dask .compute_cluster_total_resources (
140149 _scheduler_url (app ), _scheduler_auth (app ), instances
@@ -145,6 +154,7 @@ async def compute_cluster_total_resources(
145154 async def is_instance_active (
146155 self , app : FastAPI , instance : AssociatedInstance
147156 ) -> bool :
157+ assert self # nosec
148158 if not utils_docker .is_node_osparc_ready (instance .node ):
149159 return False
150160
@@ -156,11 +166,13 @@ async def is_instance_active(
156166 async def is_instance_retired (
157167 self , app : FastAPI , instance : AssociatedInstance
158168 ) -> bool :
169+ assert self # nosec
159170 if not utils_docker .is_node_osparc_ready (instance .node ):
160171 return False
161172 return await dask .is_worker_retired (
162173 _scheduler_url (app ), _scheduler_auth (app ), instance .ec2_instance
163174 )
164175
165176 async def try_retire_nodes (self , app : FastAPI ) -> None :
177+ assert self # nosec
166178 await dask .try_retire_nodes (_scheduler_url (app ), _scheduler_auth (app ))
0 commit comments