Skip to content

Commit 317273c

Browse files
committed
moved naming
1 parent ed0099a commit 317273c

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

packages/dask-task-models-library/src/dask_task_models_library/resource_constraints.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
from typing import Literal, TypedDict
1+
from typing import Final, Literal, TypedDict
22

33
from .constants import DASK_TASK_EC2_RESOURCE_RESTRICTION_KEY
44

5+
DASK_WORKER_THREAD_RESOURCE_NAME: Final[str] = "threads"
56

6-
class DaskTaskResources(TypedDict):
7+
8+
class DaskTaskResources(TypedDict, total=False):
79
CPU: float
810
RAM: int # in bytes
911
# threads is a constant of 1 (enforced by static type checkers via Literal)

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
import dask.typing
1010
import distributed
1111
from aws_library.ec2 import EC2InstanceData, Resources
12-
from dask_task_models_library.resource_constraints import DaskTaskResources
12+
from dask_task_models_library.resource_constraints import (
13+
DASK_WORKER_THREAD_RESOURCE_NAME,
14+
DaskTaskResources,
15+
)
1316
from distributed.core import Status
1417
from models_library.clusters import ClusterAuthentication, TLSAuthentication
1518
from pydantic import AnyUrl, ByteSize, TypeAdapter
@@ -39,7 +42,6 @@ async def _wrap_client_async_routine(
3942

4043

4144
_DASK_SCHEDULER_CONNECT_TIMEOUT_S: Final[int] = 5
42-
DASK_WORKER_THREAD_RESOURCE_NAME: Final[str] = "threads"
4345

4446

4547
@contextlib.asynccontextmanager

services/autoscaling/tests/unit/test_modules_dask.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
import pytest
1212
from arrow import utcnow
1313
from aws_library.ec2 import Resources
14+
from dask_task_models_library.resource_constraints import (
15+
DASK_WORKER_THREAD_RESOURCE_NAME,
16+
)
1417
from faker import Faker
1518
from models_library.clusters import (
1619
ClusterAuthentication,
@@ -31,7 +34,6 @@
3134
EC2InstanceData,
3235
)
3336
from simcore_service_autoscaling.modules.dask import (
34-
DASK_WORKER_THREAD_RESOURCE_NAME,
3537
DaskMonitoringSettings,
3638
DaskTask,
3739
_scheduler_client,
@@ -122,15 +124,13 @@ async def test_list_unrunnable_tasks(
122124
# we have nothing running now
123125
assert await list_unrunnable_tasks(scheduler_url, scheduler_authentication) == []
124126
# start a task that cannot run
125-
dask_task_impossible_resources = {"XRAM": 213}
127+
dask_task_impossible_resources = DaskTaskResources(XRAM=213, threads=1)
126128
future = create_dask_task(dask_task_impossible_resources)
127129
assert future
128130
assert await list_unrunnable_tasks(scheduler_url, scheduler_authentication) == [
129131
DaskTask(
130132
task_id=future.key,
131-
required_resources=(
132-
dask_task_impossible_resources | {DASK_WORKER_THREAD_RESOURCE_NAME: 1}
133-
),
133+
required_resources=(dask_task_impossible_resources),
134134
)
135135
]
136136
# remove that future, will remove the task
@@ -168,7 +168,7 @@ def _add_fct(x: int, y: int) -> int:
168168
next(iter(dask_spec_cluster_client.scheduler_info()["workers"])): [
169169
DaskTask(
170170
task_id=DaskTaskId(future_queued_task.key),
171-
required_resources={DASK_WORKER_THREAD_RESOURCE_NAME: 1},
171+
required_resources=DaskTaskResources(threads=1),
172172
)
173173
]
174174
}

0 commit comments

Comments
 (0)