Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrei Neagu committed Dec 16, 2024
1 parent 5b67d46 commit e9be2ee
Show file tree
Hide file tree
Showing 15 changed files with 28 additions and 24 deletions.
4 changes: 2 additions & 2 deletions packages/models-library/src/models_library/services_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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",
Expand Down
12 changes: 8 additions & 4 deletions packages/models-library/tests/test_services_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
2 changes: 1 addition & 1 deletion services/agent/tests/unit/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
),
)
Expand Down Expand Up @@ -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"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
),
)
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions services/director-v2/tests/unit/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -142,15 +142,15 @@ 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)


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(
Expand Down
2 changes: 1 addition & 1 deletion services/dynamic-sidecar/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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("/"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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("/"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit e9be2ee

Please sign in to comment.