Skip to content

Commit 3acbfc5

Browse files
add param
1 parent e3f341b commit 3acbfc5

File tree

3 files changed

+59
-37
lines changed

3 files changed

+59
-37
lines changed

packages/models-library/src/models_library/api_schemas_directorv2/dynamic_services.py

Lines changed: 56 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
from typing import TypeAlias
1+
from typing import Annotated, TypeAlias
22

3-
from pydantic import BaseModel, ByteSize, ConfigDict, Field
3+
from pydantic import AnyHttpUrl, BaseModel, ByteSize, ConfigDict, Field
4+
from pydantic.config import JsonDict
45

56
from ..resource_tracker import HardwareInfo, PricingInfo
67
from ..services import ServicePortKey
@@ -38,40 +39,60 @@ def from_transferred_bytes(
3839
class DynamicServiceCreate(ServiceDetails):
3940
service_resources: ServiceResourcesDict
4041

41-
product_name: str = Field(..., description="Current product name")
42-
can_save: bool = Field(
43-
..., description="the service data must be saved when closing"
44-
)
45-
wallet_info: WalletInfo | None = Field(
46-
default=None,
47-
description="contains information about the wallet used to bill the running service",
48-
)
49-
pricing_info: PricingInfo | None = Field(
50-
default=None,
51-
description="contains pricing information (ex. pricing plan and unit ids)",
52-
)
53-
hardware_info: HardwareInfo | None = Field(
54-
default=None,
55-
description="contains harware information (ex. aws_ec2_instances)",
56-
)
57-
model_config = ConfigDict(
58-
json_schema_extra={
59-
"example": {
60-
"key": "simcore/services/dynamic/3dviewer",
61-
"version": "2.4.5",
62-
"user_id": 234,
63-
"project_id": "dd1d04d9-d704-4f7e-8f0f-1ca60cc771fe",
64-
"node_uuid": "75c7f3f4-18f9-4678-8610-54a2ade78eaa",
65-
"basepath": "/x/75c7f3f4-18f9-4678-8610-54a2ade78eaa",
66-
"product_name": "osparc",
67-
"can_save": True,
68-
"service_resources": ServiceResourcesDictHelpers.model_config["json_schema_extra"]["examples"][0], # type: ignore [index]
69-
"wallet_info": WalletInfo.model_config["json_schema_extra"]["examples"][0], # type: ignore [index]
70-
"pricing_info": PricingInfo.model_config["json_schema_extra"]["examples"][0], # type: ignore [index]
71-
"hardware_info": HardwareInfo.model_config["json_schema_extra"]["examples"][0], # type: ignore [index]
42+
product_name: Annotated[str, Field(..., description="Current product name")]
43+
product_api_base_url: Annotated[
44+
AnyHttpUrl,
45+
Field(
46+
...,
47+
description="Base url of the product",
48+
),
49+
]
50+
can_save: Annotated[
51+
bool, Field(..., description="the service data must be saved when closing")
52+
]
53+
wallet_info: Annotated[
54+
WalletInfo | None,
55+
Field(
56+
default=None,
57+
description="contains information about the wallet used to bill the running service",
58+
),
59+
]
60+
pricing_info: Annotated[
61+
PricingInfo | None,
62+
Field(
63+
default=None,
64+
description="contains pricing information (ex. pricing plan and unit ids)",
65+
),
66+
]
67+
hardware_info: Annotated[
68+
HardwareInfo | None,
69+
Field(
70+
default=None,
71+
description="contains hardware information (ex. aws_ec2_instances)",
72+
),
73+
]
74+
75+
@staticmethod
76+
def _update_json_schema_extra(schema: JsonDict) -> None:
77+
schema.update(
78+
{
79+
"example": {
80+
"key": "simcore/services/dynamic/3dviewer",
81+
"version": "2.4.5",
82+
"user_id": 234,
83+
"project_id": "dd1d04d9-d704-4f7e-8f0f-1ca60cc771fe",
84+
"node_uuid": "75c7f3f4-18f9-4678-8610-54a2ade78eaa",
85+
"basepath": "/x/75c7f3f4-18f9-4678-8610-54a2ade78eaa",
86+
"product_name": "osparc",
87+
"product_api_base_url": "https://api.local",
88+
"can_save": True,
89+
"service_resources": ServiceResourcesDictHelpers.model_config["json_schema_extra"]["examples"][0], # type: ignore [index]
90+
"wallet_info": WalletInfo.model_config["json_schema_extra"]["examples"][0], # type: ignore [index]
91+
"pricing_info": PricingInfo.model_config["json_schema_extra"]["examples"][0], # type: ignore [index]
92+
"hardware_info": HardwareInfo.model_config["json_schema_extra"]["examples"][0], # type: ignore [index]
93+
}
7294
}
73-
}
74-
)
95+
)
7596

7697

7798
DynamicServiceGet: TypeAlias = RunningDynamicServiceDetails

services/director-v2/src/simcore_service_director_v2/models/dynamic_services_scheduler.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,7 @@ def from_http_request(
509509
"version": service.version,
510510
"service_resources": service.service_resources,
511511
"product_name": service.product_name,
512+
"product_api_base_url": service.product_api_base_url,
512513
"paths_mapping": simcore_service_labels.paths_mapping,
513514
"callbacks_mapping": simcore_service_labels.callbacks_mapping,
514515
"compose_spec": json_dumps(simcore_service_labels.compose_spec),

services/director-v2/tests/unit/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@ def simcore_service_labels() -> SimcoreServiceLabels:
7676
@pytest.fixture
7777
def dynamic_service_create() -> DynamicServiceCreate:
7878
return DynamicServiceCreate.model_validate(
79-
DynamicServiceCreate.model_config["json_schema_extra"]["example"]
79+
DynamicServiceCreate.model_json_schema()["example"]
8080
)
8181

8282

8383
@pytest.fixture
8484
def dynamic_sidecar_port() -> PortInt:
85-
return PortInt(1222)
85+
return 1222
8686

8787

8888
@pytest.fixture

0 commit comments

Comments
 (0)