diff --git a/packages/models-library/src/models_library/services_types.py b/packages/models-library/src/models_library/services_types.py index 88e8a87172f..1a464b5f780 100644 --- a/packages/models-library/src/models_library/services_types.py +++ b/packages/models-library/src/models_library/services_types.py @@ -61,7 +61,7 @@ class ServiceRunID(str): __slots__ = () @classmethod - def create_for_dynamic_sidecar(cls) -> Self: + def get_resource_tracking_run_id_for_dynamic(cls) -> Self: """used for dynamic services""" # NOTE: there was a legacy version of this RunID # legacy version: @@ -73,7 +73,7 @@ def create_for_dynamic_sidecar(cls) -> Self: return cls(run_id_format) @classmethod - def get_resource_tracking_run_id( + def get_resource_tracking_run_id_for_computational( cls, user_id: UserID, project_id: "ProjectID", diff --git a/packages/models-library/tests/test_services_types.py b/packages/models-library/tests/test_services_types.py index f2ad24b3a9f..206c531a78f 100644 --- a/packages/models-library/tests/test_services_types.py +++ b/packages/models-library/tests/test_services_types.py @@ -25,12 +25,16 @@ def test_run_id_get_resource_tracking_run_id( iteration: PositiveInt, expected_result: str, ): - resource_tracking_service_run_id = ServiceRunID.get_resource_tracking_run_id( - user_id, project_id, node_id, iteration + resource_tracking_service_run_id = ( + ServiceRunID.get_resource_tracking_run_id_for_computational( + user_id, project_id, node_id, iteration + ) ) assert isinstance(resource_tracking_service_run_id, ServiceRunID) assert resource_tracking_service_run_id == expected_result -def test_run_id_create_for_dynamic_sidecar(): - assert isinstance(ServiceRunID.create_for_dynamic_sidecar(), ServiceRunID) +def test_get_resource_tracking_run_id_for_dynamic(): + assert isinstance( + ServiceRunID.get_resource_tracking_run_id_for_dynamic(), ServiceRunID + ) diff --git a/services/agent/tests/unit/conftest.py b/services/agent/tests/unit/conftest.py index 426795c8e04..4b23619f5a0 100644 --- a/services/agent/tests/unit/conftest.py +++ b/services/agent/tests/unit/conftest.py @@ -57,7 +57,7 @@ def test_client(initialized_app: FastAPI) -> TestClient: @pytest.fixture def service_run_id() -> ServiceRunID: - return ServiceRunID.create_for_dynamic_sidecar() + return ServiceRunID.get_resource_tracking_run_id_for_dynamic() @pytest.fixture diff --git a/services/director-v2/src/simcore_service_director_v2/models/dynamic_services_scheduler.py b/services/director-v2/src/simcore_service_director_v2/models/dynamic_services_scheduler.py index ea6aa80f366..5b8b2f2c841 100644 --- a/services/director-v2/src/simcore_service_director_v2/models/dynamic_services_scheduler.py +++ b/services/director-v2/src/simcore_service_director_v2/models/dynamic_services_scheduler.py @@ -377,7 +377,7 @@ class SchedulerData(CommonServiceDetails, DynamicSidecarServiceLabels): description="Name of the current dynamic-sidecar being observed", ) run_id: ServiceRunID = Field( - default_factory=ServiceRunID.create_for_dynamic_sidecar, + default_factory=ServiceRunID.get_resource_tracking_run_id_for_dynamic, description=( "Uniquely identify the dynamic sidecar session (a.k.a. 2 " "subsequent exact same services will have a different run_id)" diff --git a/services/director-v2/src/simcore_service_director_v2/modules/comp_scheduler/_scheduler_base.py b/services/director-v2/src/simcore_service_director_v2/modules/comp_scheduler/_scheduler_base.py index 4306d251c5f..22b8677611f 100644 --- a/services/director-v2/src/simcore_service_director_v2/modules/comp_scheduler/_scheduler_base.py +++ b/services/director-v2/src/simcore_service_director_v2/modules/comp_scheduler/_scheduler_base.py @@ -295,7 +295,7 @@ def _need_heartbeat(task: CompTaskAtDB) -> bool: *( publish_service_resource_tracking_heartbeat( self.rabbitmq_client, - ServiceRunID.get_resource_tracking_run_id( + ServiceRunID.get_resource_tracking_run_id_for_computational( user_id, t.project_id, t.node_id, iteration ), ) @@ -348,7 +348,7 @@ async def _process_started_tasks( *( publish_service_resource_tracking_started( self.rabbitmq_client, - service_run_id=ServiceRunID.get_resource_tracking_run_id( + service_run_id=ServiceRunID.get_resource_tracking_run_id_for_computational( user_id, t.project_id, t.node_id, iteration ), wallet_id=run_metadata.get("wallet_id"), diff --git a/services/director-v2/src/simcore_service_director_v2/modules/comp_scheduler/_scheduler_dask.py b/services/director-v2/src/simcore_service_director_v2/modules/comp_scheduler/_scheduler_dask.py index 456e90493f9..cc33c129f1b 100644 --- a/services/director-v2/src/simcore_service_director_v2/modules/comp_scheduler/_scheduler_dask.py +++ b/services/director-v2/src/simcore_service_director_v2/modules/comp_scheduler/_scheduler_dask.py @@ -129,7 +129,7 @@ async def _start_tasks( hardware_info=task.hardware_info, callback=wake_up_callback, metadata=comp_run.metadata, - resource_tracking_run_id=ServiceRunID.get_resource_tracking_run_id( + resource_tracking_run_id=ServiceRunID.get_resource_tracking_run_id_for_computational( user_id, project_id, node_id, comp_run.iteration ), ) @@ -322,7 +322,7 @@ async def _process_task_result( # resource tracking await publish_service_resource_tracking_stopped( self.rabbitmq_client, - ServiceRunID.get_resource_tracking_run_id( + ServiceRunID.get_resource_tracking_run_id_for_computational( user_id, project_id, node_id, iteration ), simcore_platform_status=simcore_platform_status, diff --git a/services/director-v2/src/simcore_service_director_v2/modules/dynamic_sidecar/scheduler/_core/_event_create_sidecars.py b/services/director-v2/src/simcore_service_director_v2/modules/dynamic_sidecar/scheduler/_core/_event_create_sidecars.py index e8867d34d0a..8352cab1f8a 100644 --- a/services/director-v2/src/simcore_service_director_v2/modules/dynamic_sidecar/scheduler/_core/_event_create_sidecars.py +++ b/services/director-v2/src/simcore_service_director_v2/modules/dynamic_sidecar/scheduler/_core/_event_create_sidecars.py @@ -237,7 +237,7 @@ async def action(cls, app: FastAPI, scheduler_data: SchedulerData) -> None: # Each time a new dynamic-sidecar service is created # generate a new `run_id` to avoid resource collisions - scheduler_data.run_id = ServiceRunID.create_for_dynamic_sidecar() + scheduler_data.run_id = ServiceRunID.get_resource_tracking_run_id_for_dynamic() rpc_client: RabbitMQRPCClient = app.state.rabbitmq_rpc_client diff --git a/services/director-v2/tests/unit/conftest.py b/services/director-v2/tests/unit/conftest.py index dfd89de9fab..7a6ab8e439d 100644 --- a/services/director-v2/tests/unit/conftest.py +++ b/services/director-v2/tests/unit/conftest.py @@ -80,14 +80,14 @@ def dynamic_sidecar_port() -> PortInt: @pytest.fixture def service_run_id() -> ServiceRunID: - return ServiceRunID.create_for_dynamic_sidecar() + return ServiceRunID.get_resource_tracking_run_id_for_dynamic() @pytest.fixture def resource_tracking_run_id( user_id: UserID, project_id: ProjectID, node_id: NodeID ) -> ServiceRunID: - return ServiceRunID.get_resource_tracking_run_id( + return ServiceRunID.get_resource_tracking_run_id_for_computational( user_id, project_id, node_id, iteration=42 ) diff --git a/services/director-v2/tests/unit/test_modules_dynamic_sidecar_volumes_resolver.py b/services/director-v2/tests/unit/test_modules_dynamic_sidecar_volumes_resolver.py index 313e1da9db0..4acacd3a4e4 100644 --- a/services/director-v2/tests/unit/test_modules_dynamic_sidecar_volumes_resolver.py +++ b/services/director-v2/tests/unit/test_modules_dynamic_sidecar_volumes_resolver.py @@ -37,7 +37,7 @@ def state_paths() -> list[Path]: @pytest.fixture def service_run_id() -> ServiceRunID: - return ServiceRunID.create_for_dynamic_sidecar() + return ServiceRunID.get_resource_tracking_run_id_for_dynamic() @pytest.fixture @@ -142,7 +142,7 @@ async def test_unique_name_creation_and_removal(faker: Faker): unique_volume_name = DynamicSidecarVolumesPathsResolver.source( path=Path("/some/random/path/to/a/workspace/folder"), node_uuid=faker.uuid4(cast_to=None), - service_run_id=ServiceRunID.create_for_dynamic_sidecar(), + service_run_id=ServiceRunID.get_resource_tracking_run_id_for_dynamic(), ) await assert_creation_and_removal(unique_volume_name) @@ -150,7 +150,7 @@ async def test_unique_name_creation_and_removal(faker: Faker): def test_volumes_get_truncated_as_expected(faker: Faker): node_uuid = faker.uuid4(cast_to=None) - service_run_id = ServiceRunID.create_for_dynamic_sidecar() + service_run_id = ServiceRunID.get_resource_tracking_run_id_for_dynamic() assert node_uuid != service_run_id unique_volume_name = DynamicSidecarVolumesPathsResolver.source( path=Path( diff --git a/services/dynamic-sidecar/tests/conftest.py b/services/dynamic-sidecar/tests/conftest.py index ff0586396f7..5ad10622acd 100644 --- a/services/dynamic-sidecar/tests/conftest.py +++ b/services/dynamic-sidecar/tests/conftest.py @@ -125,7 +125,7 @@ def node_id(faker: Faker) -> NodeID: @pytest.fixture def service_run_id() -> ServiceRunID: - return ServiceRunID.create_for_dynamic_sidecar() + return ServiceRunID.get_resource_tracking_run_id_for_dynamic() @pytest.fixture diff --git a/services/dynamic-sidecar/tests/unit/test_core_docker_utils.py b/services/dynamic-sidecar/tests/unit/test_core_docker_utils.py index ad5d70f0f80..bf647faa5e4 100644 --- a/services/dynamic-sidecar/tests/unit/test_core_docker_utils.py +++ b/services/dynamic-sidecar/tests/unit/test_core_docker_utils.py @@ -29,7 +29,7 @@ def volume_name() -> str: @pytest.fixture def service_run_id() -> ServiceRunID: - return ServiceRunID.create_for_dynamic_sidecar() + return ServiceRunID.get_resource_tracking_run_id_for_dynamic() @pytest.fixture diff --git a/services/dynamic-sidecar/tests/unit/test_core_validation.py b/services/dynamic-sidecar/tests/unit/test_core_validation.py index 95118d15374..f9af97453bd 100644 --- a/services/dynamic-sidecar/tests/unit/test_core_validation.py +++ b/services/dynamic-sidecar/tests/unit/test_core_validation.py @@ -156,7 +156,7 @@ def no_internet_spec(project_tests_dir: Path) -> str: @pytest.fixture def fake_mounted_volumes() -> MountedVolumes: return MountedVolumes( - service_run_id=ServiceRunID.create_for_dynamic_sidecar(), + service_run_id=ServiceRunID.get_resource_tracking_run_id_for_dynamic(), node_id=NodeID("a019b83f-7cce-46bf-90cf-d02f7f0f089a"), inputs_path=Path("/"), outputs_path=Path("/"), diff --git a/services/dynamic-sidecar/tests/unit/test_modules_outputs_manager.py b/services/dynamic-sidecar/tests/unit/test_modules_outputs_manager.py index 5e869d0908b..f4e5c2dd18c 100644 --- a/services/dynamic-sidecar/tests/unit/test_modules_outputs_manager.py +++ b/services/dynamic-sidecar/tests/unit/test_modules_outputs_manager.py @@ -371,7 +371,7 @@ async def test_regression_io_log_redirect_cb( monkeypatch.setenv("RABBIT_SECURE", "false") mounted_volumes = MountedVolumes( - service_run_id=ServiceRunID.create_for_dynamic_sidecar(), + service_run_id=ServiceRunID.get_resource_tracking_run_id_for_dynamic(), node_id=faker.uuid4(cast_to=None), inputs_path=Path("/"), outputs_path=Path("/"), diff --git a/services/dynamic-sidecar/tests/unit/test_modules_outputs_watcher.py b/services/dynamic-sidecar/tests/unit/test_modules_outputs_watcher.py index 7cbfd56056c..eeea009cc32 100644 --- a/services/dynamic-sidecar/tests/unit/test_modules_outputs_watcher.py +++ b/services/dynamic-sidecar/tests/unit/test_modules_outputs_watcher.py @@ -63,7 +63,7 @@ @pytest.fixture def mounted_volumes(faker: Faker, tmp_path: Path) -> Iterator[MountedVolumes]: mounted_volumes = MountedVolumes( - service_run_id=ServiceRunID.create_for_dynamic_sidecar(), + service_run_id=ServiceRunID.get_resource_tracking_run_id_for_dynamic(), node_id=faker.uuid4(cast_to=None), inputs_path=tmp_path / "inputs", outputs_path=tmp_path / "outputs", diff --git a/services/dynamic-sidecar/tests/unit/test_modules_system_monitor__disk_usage.py b/services/dynamic-sidecar/tests/unit/test_modules_system_monitor__disk_usage.py index 31ba1b01698..5cac0f59934 100644 --- a/services/dynamic-sidecar/tests/unit/test_modules_system_monitor__disk_usage.py +++ b/services/dynamic-sidecar/tests/unit/test_modules_system_monitor__disk_usage.py @@ -42,7 +42,7 @@ def _( inputs: Path, outputs: Path, states: list[Path] ) -> dict[MountPathCategory, set[Path]]: mounted_volumes = MountedVolumes( - service_run_id=ServiceRunID.create_for_dynamic_sidecar(), + service_run_id=ServiceRunID.get_resource_tracking_run_id_for_dynamic(), node_id=node_id, inputs_path=dy_volumes / inputs, outputs_path=dy_volumes / outputs,