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 c7e28d41428..7e9b3ebeac6 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 @@ -464,9 +464,13 @@ def get_proxy_endpoint(self) -> AnyHttpUrl: ) return url - product_name: str = Field( - description="Current product upon which this service is scheduled" - ) + product_name: Annotated[ + str | None, + Field( + description="Current product upon which this service is scheduled" + "If set to None, the current product is undefined. Mostly for backwards compatibility", + ), + ] = None @classmethod def from_http_request( diff --git a/services/director-v2/src/simcore_service_director_v2/modules/dynamic_sidecar/docker_service_specs/proxy.py b/services/director-v2/src/simcore_service_director_v2/modules/dynamic_sidecar/docker_service_specs/proxy.py index b946e71d4ea..07b1adbb08b 100644 --- a/services/director-v2/src/simcore_service_director_v2/modules/dynamic_sidecar/docker_service_specs/proxy.py +++ b/services/director-v2/src/simcore_service_director_v2/modules/dynamic_sidecar/docker_service_specs/proxy.py @@ -35,6 +35,9 @@ def get_dynamic_proxy_spec( The proxy is used to create network isolation from the rest of the platform. """ + assert ( + scheduler_data.product_name is not None + ), "ONLY for legacy. This function should not be called with product_name==None" # nosec proxy_settings: DynamicSidecarProxySettings = ( dynamic_services_settings.DYNAMIC_SIDECAR_PROXY_SETTINGS diff --git a/services/director-v2/src/simcore_service_director_v2/modules/dynamic_sidecar/docker_service_specs/sidecar.py b/services/director-v2/src/simcore_service_director_v2/modules/dynamic_sidecar/docker_service_specs/sidecar.py index b6885bae7b3..4ee83bee16f 100644 --- a/services/director-v2/src/simcore_service_director_v2/modules/dynamic_sidecar/docker_service_specs/sidecar.py +++ b/services/director-v2/src/simcore_service_director_v2/modules/dynamic_sidecar/docker_service_specs/sidecar.py @@ -447,6 +447,10 @@ async def get_dynamic_sidecar_spec( # pylint:disable=too-many-arguments# noqa: dynamic_sidecar_settings=dynamic_sidecar_settings, app_settings=app_settings ) + assert ( + scheduler_data.product_name is not None + ), "ONLY for legacy. This function should not be called with product_name==None" # nosec + standard_simcore_docker_labels: dict[ DockerLabelKey, str ] = StandardSimcoreDockerLabels( 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 abf052f4e12..c6a4cba08f3 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 @@ -199,7 +199,9 @@ async def action(cls, app: FastAPI, scheduler_data: SchedulerData) -> None: groups_extra_properties = get_repository(app, GroupsExtraPropertiesRepository) - assert scheduler_data.product_name is not None # nosec + assert ( + scheduler_data.product_name is not None + ), "ONLY for legacy. This function should not be called with product_name==None" # nosec user_extra_properties = await groups_extra_properties.get_user_extra_properties( user_id=scheduler_data.user_id, product_name=scheduler_data.product_name diff --git a/services/director-v2/src/simcore_service_director_v2/modules/dynamic_sidecar/scheduler/_core/_events_user_services.py b/services/director-v2/src/simcore_service_director_v2/modules/dynamic_sidecar/scheduler/_core/_events_user_services.py index f8416b4809b..b00b4e568f1 100644 --- a/services/director-v2/src/simcore_service_director_v2/modules/dynamic_sidecar/scheduler/_core/_events_user_services.py +++ b/services/director-v2/src/simcore_service_director_v2/modules/dynamic_sidecar/scheduler/_core/_events_user_services.py @@ -73,7 +73,9 @@ async def submit_compose_sepc(app: FastAPI, scheduler_data: SchedulerData) -> No ) groups_extra_properties = get_repository(app, GroupsExtraPropertiesRepository) - assert scheduler_data.product_name is not None # nosec + assert ( + scheduler_data.product_name is not None + ), "ONLY for legacy. This function should not be called with product_name==None" # nosec allow_internet_access: bool = await groups_extra_properties.has_internet_access( user_id=scheduler_data.user_id, product_name=scheduler_data.product_name ) @@ -168,7 +170,9 @@ async def progress_create_containers( project_name=project_name, node_name=node_name, service_key=scheduler_data.key, - service_version=TypeAdapter(ServiceVersion).validate_python(scheduler_data.version), + service_version=TypeAdapter(ServiceVersion).validate_python( + scheduler_data.version + ), service_resources=scheduler_data.service_resources, service_additional_metadata={}, ) diff --git a/services/director-v2/tests/unit/conftest.py b/services/director-v2/tests/unit/conftest.py index b305f6bcafd..ab5877a8680 100644 --- a/services/director-v2/tests/unit/conftest.py +++ b/services/director-v2/tests/unit/conftest.py @@ -51,8 +51,11 @@ def simcore_services_network_name() -> str: @pytest.fixture def simcore_service_labels() -> SimcoreServiceLabels: + json_schema_extra = {} + SimcoreServiceLabels.model_config["json_schema_extra"](json_schema_extra) + simcore_service_labels = SimcoreServiceLabels.model_validate( - SimcoreServiceLabels.model_config["json_schema_extra"]["examples"][1] + json_schema_extra["examples"][1] ) simcore_service_labels.callbacks_mapping = CallbacksMapping.model_validate({}) return simcore_service_labels