Skip to content

Commit 2023c10

Browse files
committed
simplify
1 parent 48dab2d commit 2023c10

File tree

1 file changed

+5
-10
lines changed
  • services/autoscaling/src/simcore_service_autoscaling/modules

1 file changed

+5
-10
lines changed

services/autoscaling/src/simcore_service_autoscaling/modules/dask.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
node_host_name_from_ec2_private_dns,
2929
node_ip_from_ec2_private_dns,
3030
)
31+
from .cluster_scaling._utils_computational import (
32+
resources_from_dask_task,
33+
)
3134

3235
_logger = logging.getLogger(__name__)
3336

@@ -285,20 +288,12 @@ async def get_worker_used_resources(
285288
if not worker_processing_tasks:
286289
return Resources.create_as_empty()
287290

288-
total_resources_used: collections.Counter[str] = collections.Counter()
291+
total_resources_used: collections.Counter = collections.Counter()
289292
for _, task_resources in worker_processing_tasks:
290293
total_resources_used.update(task_resources)
291294

292295
_logger.debug("found %s for %s", f"{total_resources_used=}", f"{worker_url=}")
293-
return Resources(
294-
cpus=total_resources_used.get("CPU", 0),
295-
ram=TypeAdapter(ByteSize).validate_python(
296-
total_resources_used.get("RAM", 0)
297-
),
298-
generic_resources={
299-
k: v for k, v in total_resources_used.items() if k not in {"CPU", "RAM"}
300-
},
301-
)
296+
return resources_from_dask_task(total_resources_used)
302297

303298

304299
async def compute_cluster_total_resources(

0 commit comments

Comments
 (0)