66
77import asyncio
88import concurrent .futures
9- import logging
109import time
1110from collections .abc import AsyncIterator , Callable , Coroutine
1211from typing import Any
1312
1413import distributed
1514import pytest
1615from dask_task_models_library .container_tasks .errors import TaskCancelledError
17- from dask_task_models_library .container_tasks .events import TaskLogEvent
16+ from dask_task_models_library .container_tasks .events import TaskProgressEvent
1817from dask_task_models_library .container_tasks .io import TaskCancelEventName
1918from dask_task_models_library .container_tasks .protocol import TaskOwner
2019from simcore_service_dask_sidecar .dask_utils import (
3332DASK_TASK_STARTED_EVENT = "task_started"
3433DASK_TESTING_TIMEOUT_S = 25
3534
35+ pytest_simcore_core_services_selection = [
36+ "rabbit" ,
37+ ]
38+
3639
3740def test_publish_event (
3841 dask_client : distributed .Client , job_id : str , task_owner : TaskOwner
3942):
4043 dask_pub = distributed .Pub ("some_topic" , client = dask_client )
4144 dask_sub = distributed .Sub ("some_topic" , client = dask_client )
42- event_to_publish = TaskLogEvent (
45+ event_to_publish = TaskProgressEvent (
4346 job_id = job_id ,
44- log = "the log" ,
45- log_level = logging . INFO ,
47+ msg = "the log" ,
48+ progress = 1 ,
4649 task_owner = task_owner ,
4750 )
4851 publish_event (dask_pub = dask_pub , event = event_to_publish )
@@ -53,7 +56,7 @@ def test_publish_event(
5356 message = dask_sub .get (timeout = DASK_TESTING_TIMEOUT_S )
5457 assert message is not None
5558 assert isinstance (message , str )
56- received_task_log_event = TaskLogEvent .model_validate_json (message )
59+ received_task_log_event = TaskProgressEvent .model_validate_json (message )
5760 assert received_task_log_event == event_to_publish
5861
5962
@@ -62,8 +65,8 @@ async def test_publish_event_async(
6265):
6366 dask_pub = distributed .Pub ("some_topic" , client = async_dask_client )
6467 dask_sub = distributed .Sub ("some_topic" , client = async_dask_client )
65- event_to_publish = TaskLogEvent (
66- job_id = job_id , log = "the log" , log_level = logging . INFO , task_owner = task_owner
68+ event_to_publish = TaskProgressEvent (
69+ job_id = job_id , msg = "the log" , progress = 2 , task_owner = task_owner
6770 )
6871 publish_event (dask_pub = dask_pub , event = event_to_publish )
6972
@@ -74,7 +77,7 @@ async def test_publish_event_async(
7477 assert isinstance (message , Coroutine )
7578 message = await message
7679 assert message is not None
77- received_task_log_event = TaskLogEvent .model_validate_json (message )
80+ received_task_log_event = TaskProgressEvent .model_validate_json (message )
7881 assert received_task_log_event == event_to_publish
7982
8083
@@ -117,11 +120,10 @@ async def _dask_sub_consumer_task(sub: distributed.Sub) -> None:
117120
118121 async def _dask_publisher_task (pub : distributed .Pub ) -> None :
119122 print ("--> starting publisher task" )
120- for n in range (NUMBER_OF_MESSAGES ):
121- event_to_publish = TaskLogEvent (
123+ for _ in range (NUMBER_OF_MESSAGES ):
124+ event_to_publish = TaskProgressEvent (
122125 job_id = job_id ,
123- log = f"the log { n } " ,
124- log_level = logging .INFO ,
126+ progress = 0.5 ,
125127 task_owner = task_owner ,
126128 )
127129 publish_event (dask_pub = pub , event = event_to_publish )
0 commit comments