Skip to content

Commit

Permalink
fixes director
Browse files Browse the repository at this point in the history
  • Loading branch information
pcrespov committed Dec 3, 2024
1 parent 72a7da1 commit 0b83488
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down Expand Up @@ -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={},
)
Expand Down
5 changes: 4 additions & 1 deletion services/director-v2/tests/unit/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0b83488

Please sign in to comment.