4646from models_library .projects_nodes_io import NodeID
4747from models_library .resource_tracker import HardwareInfo
4848from models_library .users import UserID
49- from pydantic import AnyUrl , ByteSize , TypeAdapter
49+ from pydantic import AnyUrl , ByteSize , PositiveInt , TypeAdapter
5050from pytest_mock .plugin import MockerFixture
5151from pytest_simcore .helpers .typing_env import EnvVarsDict
5252from settings_library .s3 import S3Settings
@@ -442,6 +442,7 @@ async def test_send_computation_task(
442442 task_labels : ContainerLabelsDict ,
443443 empty_hardware_info : HardwareInfo ,
444444 faker : Faker ,
445+ comp_task_run_id : PositiveInt ,
445446):
446447 _DASK_EVENT_NAME = faker .pystr ()
447448
@@ -503,7 +504,7 @@ def fake_sidecar_fct(
503504 ),
504505 metadata = comp_run_metadata ,
505506 hardware_info = empty_hardware_info ,
506- run_id = 1 ,
507+ run_id = comp_task_run_id ,
507508 )
508509 assert node_id_to_job_ids
509510 assert len (node_id_to_job_ids ) == 1
@@ -560,6 +561,7 @@ async def test_computation_task_is_persisted_on_dask_scheduler(
560561 mocked_storage_service_api : respx .MockRouter ,
561562 comp_run_metadata : RunMetadataDict ,
562563 empty_hardware_info : HardwareInfo ,
564+ comp_task_run_id : PositiveInt ,
563565):
564566 """rationale:
565567 When a task is submitted to the dask backend, a dask future is returned.
@@ -595,7 +597,7 @@ def fake_sidecar_fct(
595597 remote_fct = fake_sidecar_fct ,
596598 metadata = comp_run_metadata ,
597599 hardware_info = empty_hardware_info ,
598- run_id = 1 ,
600+ run_id = comp_task_run_id ,
599601 )
600602 assert published_computation_task
601603 assert len (published_computation_task ) == 1
@@ -651,6 +653,7 @@ async def test_abort_computation_tasks(
651653 faker : Faker ,
652654 comp_run_metadata : RunMetadataDict ,
653655 empty_hardware_info : HardwareInfo ,
656+ comp_task_run_id : PositiveInt ,
654657):
655658 _DASK_EVENT_NAME = faker .pystr ()
656659
@@ -689,6 +692,7 @@ def fake_remote_fct(
689692 remote_fct = fake_remote_fct ,
690693 metadata = comp_run_metadata ,
691694 hardware_info = empty_hardware_info ,
695+ run_id = comp_task_run_id ,
692696 )
693697 assert published_computation_task
694698 assert len (published_computation_task ) == 1
@@ -740,6 +744,7 @@ async def test_failed_task_returns_exceptions(
740744 mocked_storage_service_api : respx .MockRouter ,
741745 comp_run_metadata : RunMetadataDict ,
742746 empty_hardware_info : HardwareInfo ,
747+ comp_task_run_id : PositiveInt ,
743748):
744749 # NOTE: this must be inlined so that the test works,
745750 # the dask-worker must be able to import the function
@@ -760,6 +765,7 @@ def fake_failing_sidecar_fct(
760765 remote_fct = fake_failing_sidecar_fct ,
761766 metadata = comp_run_metadata ,
762767 hardware_info = empty_hardware_info ,
768+ run_id = comp_task_run_id ,
763769 )
764770 assert published_computation_task
765771 assert len (published_computation_task ) == 1
@@ -802,6 +808,7 @@ async def test_send_computation_task_with_missing_resources_raises(
802808 mocked_storage_service_api : respx .MockRouter ,
803809 comp_run_metadata : RunMetadataDict ,
804810 empty_hardware_info : HardwareInfo ,
811+ comp_task_run_id : PositiveInt ,
805812):
806813 # remove the workers that can handle gpu
807814 scheduler_info = dask_client .backend .client .scheduler_info ()
@@ -828,6 +835,7 @@ async def test_send_computation_task_with_missing_resources_raises(
828835 remote_fct = None ,
829836 metadata = comp_run_metadata ,
830837 hardware_info = empty_hardware_info ,
838+ run_id = comp_task_run_id ,
831839 )
832840 mocked_user_completed_cb .assert_not_called ()
833841
@@ -846,6 +854,7 @@ async def test_send_computation_task_with_hardware_info_raises(
846854 mocked_storage_service_api : respx .MockRouter ,
847855 comp_run_metadata : RunMetadataDict ,
848856 hardware_info : HardwareInfo ,
857+ comp_task_run_id : PositiveInt ,
849858):
850859 # NOTE: running on the default cluster will raise missing resources
851860 with pytest .raises (MissingComputationalResourcesError ):
@@ -857,6 +866,7 @@ async def test_send_computation_task_with_hardware_info_raises(
857866 remote_fct = None ,
858867 metadata = comp_run_metadata ,
859868 hardware_info = hardware_info ,
869+ run_id = comp_task_run_id ,
860870 )
861871 mocked_user_completed_cb .assert_not_called ()
862872
@@ -874,6 +884,7 @@ async def test_too_many_resources_send_computation_task(
874884 mocked_storage_service_api : respx .MockRouter ,
875885 comp_run_metadata : RunMetadataDict ,
876886 empty_hardware_info : HardwareInfo ,
887+ comp_task_run_id : PositiveInt ,
877888):
878889 # create an image that needs a huge amount of CPU
879890 image = Image (
@@ -897,6 +908,7 @@ async def test_too_many_resources_send_computation_task(
897908 remote_fct = None ,
898909 metadata = comp_run_metadata ,
899910 hardware_info = empty_hardware_info ,
911+ run_id = comp_task_run_id ,
900912 )
901913
902914 mocked_user_completed_cb .assert_not_called ()
@@ -913,6 +925,7 @@ async def test_disconnected_backend_raises_exception(
913925 mocked_storage_service_api : respx .MockRouter ,
914926 comp_run_metadata : RunMetadataDict ,
915927 empty_hardware_info : HardwareInfo ,
928+ comp_task_run_id : PositiveInt ,
916929):
917930 # DISCONNECT THE CLUSTER
918931 await dask_spec_local_cluster .close () # type: ignore
@@ -925,6 +938,7 @@ async def test_disconnected_backend_raises_exception(
925938 remote_fct = None ,
926939 metadata = comp_run_metadata ,
927940 hardware_info = empty_hardware_info ,
941+ run_id = comp_task_run_id ,
928942 )
929943 mocked_user_completed_cb .assert_not_called ()
930944
@@ -944,6 +958,7 @@ async def test_changed_scheduler_raises_exception(
944958 unused_tcp_port_factory : Callable ,
945959 comp_run_metadata : RunMetadataDict ,
946960 empty_hardware_info : HardwareInfo ,
961+ comp_task_run_id : PositiveInt ,
947962):
948963 # change the scheduler (stop the current one and start another at the same address)
949964 scheduler_address = URL (dask_spec_local_cluster .scheduler_address )
@@ -973,6 +988,7 @@ async def test_changed_scheduler_raises_exception(
973988 remote_fct = None ,
974989 metadata = comp_run_metadata ,
975990 hardware_info = empty_hardware_info ,
991+ run_id = comp_task_run_id ,
976992 )
977993 mocked_user_completed_cb .assert_not_called ()
978994
@@ -990,6 +1006,7 @@ async def test_get_tasks_status(
9901006 fail_remote_fct : bool ,
9911007 comp_run_metadata : RunMetadataDict ,
9921008 empty_hardware_info : HardwareInfo ,
1009+ comp_task_run_id : PositiveInt ,
9931010):
9941011 # NOTE: this must be inlined so that the test works,
9951012 # the dask-worker must be able to import the function
@@ -1017,6 +1034,7 @@ def fake_remote_fct(
10171034 remote_fct = fake_remote_fct ,
10181035 metadata = comp_run_metadata ,
10191036 hardware_info = empty_hardware_info ,
1037+ run_id = comp_task_run_id ,
10201038 )
10211039 assert published_computation_task
10221040 assert len (published_computation_task ) == 1
@@ -1071,6 +1089,7 @@ async def test_dask_sub_handlers(
10711089 fake_task_handlers : TaskHandlers ,
10721090 comp_run_metadata : RunMetadataDict ,
10731091 empty_hardware_info : HardwareInfo ,
1092+ comp_task_run_id : PositiveInt ,
10741093):
10751094 dask_client .register_handlers (fake_task_handlers )
10761095 _DASK_START_EVENT = "start"
@@ -1100,6 +1119,7 @@ def fake_remote_fct(
11001119 remote_fct = fake_remote_fct ,
11011120 metadata = comp_run_metadata ,
11021121 hardware_info = empty_hardware_info ,
1122+ run_id = comp_task_run_id ,
11031123 )
11041124 assert published_computation_task
11051125 assert len (published_computation_task ) == 1
@@ -1144,6 +1164,7 @@ async def test_get_cluster_details(
11441164 comp_run_metadata : RunMetadataDict ,
11451165 empty_hardware_info : HardwareInfo ,
11461166 faker : Faker ,
1167+ comp_task_run_id : PositiveInt ,
11471168):
11481169 cluster_details = await dask_client .get_cluster_details ()
11491170 assert cluster_details
@@ -1180,6 +1201,7 @@ def fake_sidecar_fct(
11801201 ),
11811202 metadata = comp_run_metadata ,
11821203 hardware_info = empty_hardware_info ,
1204+ run_id = comp_task_run_id ,
11831205 )
11841206 assert published_computation_task
11851207 assert len (published_computation_task ) == 1
0 commit comments