99import traceback
1010from collections .abc import AsyncIterator , Awaitable , Callable , Coroutine
1111from dataclasses import dataclass
12- from typing import Any , NoReturn
12+ from inspect import isawaitable
13+ from typing import Any , NoReturn , cast
1314from unittest import mock
1415from uuid import uuid4
1516
@@ -364,7 +365,9 @@ def fct_that_raise_cancellation_error() -> NoReturn:
364365async def test_dask_does_not_report_base_exception_in_task (dask_client : DaskClient ):
365366 def fct_that_raise_base_exception () -> NoReturn :
366367 err_msg = "task triggers a base exception, but dask does not care..."
367- raise BaseException (err_msg ) # pylint: disable=broad-exception-raised
368+ raise BaseException ( # pylint: disable=broad-exception-raised # noqa: TRY002
369+ err_msg
370+ )
368371
369372 future = dask_client .backend .client .submit (fct_that_raise_base_exception )
370373 # NOTE: Since asyncio.CancelledError is derived from BaseException and the worker code checks Exception only
@@ -402,7 +405,7 @@ def comp_run_metadata(faker: Faker) -> RunMetadataDict:
402405 return RunMetadataDict (
403406 product_name = faker .pystr (),
404407 simcore_user_agent = faker .pystr (),
405- ) | faker .pydict (allowed_types = (str ,))
408+ ) | cast ( dict [ str , str ], faker .pydict (allowed_types = (str ,) ))
406409
407410
408411@pytest .fixture
@@ -418,6 +421,9 @@ def task_labels(comp_run_metadata: RunMetadataDict) -> ContainerLabelsDict:
418421
419422@pytest .fixture
420423def hardware_info () -> HardwareInfo :
424+ assert "json_schema_extra" in HardwareInfo .model_config
425+ assert isinstance (HardwareInfo .model_config ["json_schema_extra" ], dict )
426+ assert isinstance (HardwareInfo .model_config ["json_schema_extra" ]["examples" ], list )
421427 return HardwareInfo .model_validate (
422428 HardwareInfo .model_config ["json_schema_extra" ]["examples" ][0 ]
423429 )
@@ -476,7 +482,9 @@ def fake_sidecar_fct(
476482 assert node_params .node_requirements .ram
477483 assert "product_name" in comp_run_metadata
478484 assert "simcore_user_agent" in comp_run_metadata
479- assert image_params .fake_tasks [node_id ].node_requirements is not None
485+ node_requirements = image_params .fake_tasks [node_id ].node_requirements
486+ assert node_requirements
487+
480488 node_id_to_job_ids = await dask_client .send_computation_tasks (
481489 user_id = user_id ,
482490 project_id = project_id ,
@@ -491,8 +499,8 @@ def fake_sidecar_fct(
491499 f"{ to_simcore_runtime_docker_label_key ('user-id' )} " : f"{ user_id } " ,
492500 f"{ to_simcore_runtime_docker_label_key ('project-id' )} " : f"{ project_id } " ,
493501 f"{ to_simcore_runtime_docker_label_key ('node-id' )} " : f"{ node_id } " ,
494- f"{ to_simcore_runtime_docker_label_key ('cpu-limit' )} " : f"{ image_params . fake_tasks [ node_id ]. node_requirements .cpu } " ,
495- f"{ to_simcore_runtime_docker_label_key ('memory-limit' )} " : f"{ image_params . fake_tasks [ node_id ]. node_requirements .ram } " ,
502+ f"{ to_simcore_runtime_docker_label_key ('cpu-limit' )} " : f"{ node_requirements .cpu } " ,
503+ f"{ to_simcore_runtime_docker_label_key ('memory-limit' )} " : f"{ node_requirements .ram } " ,
496504 f"{ to_simcore_runtime_docker_label_key ('product-name' )} " : f"{ comp_run_metadata ['product_name' ]} " ,
497505 f"{ to_simcore_runtime_docker_label_key ('simcore-user-agent' )} " : f"{ comp_run_metadata ['simcore_user_agent' ]} " ,
498506 f"{ to_simcore_runtime_docker_label_key ('swarm-stack-name' )} " : "undefined-label" ,
@@ -1103,9 +1111,13 @@ def fake_remote_fct(
11031111 assert len (published_computation_task ) == 1
11041112
11051113 assert published_computation_task [0 ].node_id in cpu_image .fake_tasks
1106- computation_future = distributed .Future (published_computation_task [0 ].job_id )
1114+ computation_future = distributed .Future (
1115+ published_computation_task [0 ].job_id , client = dask_client .backend .client
1116+ )
11071117 print ("--> waiting for job to finish..." )
1108- await distributed .wait (computation_future , timeout = _ALLOW_TIME_FOR_GATEWAY_TO_CREATE_WORKERS ) # type: ignore
1118+ await distributed .wait (
1119+ computation_future , timeout = _ALLOW_TIME_FOR_GATEWAY_TO_CREATE_WORKERS
1120+ )
11091121 assert computation_future .done ()
11101122 print ("job finished, now checking that we received the publications..." )
11111123
0 commit comments