Skip to content

Commit 78b8ec7

Browse files
committed
@mguidon request: speag phantoms
1 parent 9285a98 commit 78b8ec7

File tree

4 files changed

+47
-13
lines changed

4 files changed

+47
-13
lines changed

.env-devel

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,10 @@ FUNCTION_SERVICES_AUTHORS='{"UN": {"name": "Unknown", "email": "[email protected]
135135

136136
WEBSERVER_LICENSES={}
137137
LICENSES_ITIS_VIP_SYNCER_ENABLED=false
138-
LICENSES_ITIS_VIP_API_URL=https://some-api/{category}
138+
LICENSES_ITIS_VIP_API_URL=https://replace-with-itis-api/{category}
139139
LICENSES_ITIS_VIP_CATEGORIES='{"HumanWholeBody": "Humans", "HumanBodyRegion": "Humans (Region)", "AnimalWholeBody": "Animal"}'
140+
LICENSES_SPEAG_PHANTOMS_API_URL=https://replace-with-speag-api/{category}
141+
LICENSES_SPEAG_PHANTOMS_CATEGORIES='{"ComputationalPhantom": "Phantom of the Opera"}'
140142

141143
# Can use 'docker run -it itisfoundation/invitations:latest simcore-service-invitations generate-dotenv --auto-password'
142144
INVITATIONS_DEFAULT_PRODUCT=osparc

services/docker-compose.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,9 @@ services:
708708
LICENSES_ITIS_VIP_SYNCER_ENABLED : ${LICENSES_ITIS_VIP_SYNCER_ENABLED}
709709
LICENSES_ITIS_VIP_API_URL: ${LICENSES_ITIS_VIP_API_URL}
710710
LICENSES_ITIS_VIP_CATEGORIES: ${LICENSES_ITIS_VIP_CATEGORIES}
711+
LICENSES_SPEAG_PHANTOMS_API_URL: ${LICENSES_SPEAG_PHANTOMS_API_URL}
712+
LICENSES_SPEAG_PHANTOMS_CATEGORIES: ${LICENSES_SPEAG_PHANTOMS_CATEGORIES}
713+
711714

712715
WEBSERVER_LOGIN: ${WEBSERVER_LOGIN}
713716
LOGIN_ACCOUNT_DELETION_RETENTION_DAYS: ${LOGIN_ACCOUNT_DELETION_RETENTION_DAYS}

services/web/server/src/simcore_service_webserver/licenses/_itis_vip_settings.py

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,19 @@ def _validate_url_contains_category(url: str) -> str:
1313
return url
1414

1515

16+
def _to_categories(
17+
api_url: str, category_map: dict[CategoryID, CategoryDisplay]
18+
) -> list[CategoryTuple]:
19+
return [
20+
CategoryTuple(
21+
url=HttpUrl(api_url.format(category=category_id)),
22+
id=category_id,
23+
display=category_display,
24+
)
25+
for category_id, category_display in category_map.items()
26+
]
27+
28+
1629
class ItisVipSettings(BaseCustomSettings):
1730
LICENSES_ITIS_VIP_API_URL: Annotated[
1831
str, AfterValidator(_validate_url_contains_category)
@@ -26,13 +39,20 @@ def get_urls(self) -> list[HttpUrl]:
2639
]
2740

2841
def to_categories(self) -> list[CategoryTuple]:
29-
return [
30-
CategoryTuple(
31-
url=HttpUrl(
32-
self.LICENSES_ITIS_VIP_API_URL.format(category=category_id)
33-
),
34-
id=category_id,
35-
display=category_display,
36-
)
37-
for category_id, category_display in self.LICENSES_ITIS_VIP_CATEGORIES.items()
38-
]
42+
return _to_categories(
43+
self.LICENSES_ITIS_VIP_API_URL,
44+
self.LICENSES_ITIS_VIP_CATEGORIES,
45+
)
46+
47+
48+
class SpeagPhantomsSettings(BaseCustomSettings):
49+
LICENSES_SPEAG_PHANTOMS_API_URL: Annotated[
50+
str, AfterValidator(_validate_url_contains_category)
51+
]
52+
LICENSES_SPEAG_PHANTOMS_CATEGORIES: dict[CategoryID, CategoryDisplay]
53+
54+
def to_categories(self) -> list[CategoryTuple]:
55+
return _to_categories(
56+
self.LICENSES_SPEAG_PHANTOMS_API_URL,
57+
self.LICENSES_SPEAG_PHANTOMS_CATEGORIES,
58+
)

services/web/server/src/simcore_service_webserver/licenses/settings.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
from servicelib.aiohttp.application_keys import APP_SETTINGS_KEY
77
from settings_library.base import BaseCustomSettings
88

9-
from ._itis_vip_settings import ItisVipSettings
9+
from ._itis_vip_settings import ItisVipSettings, SpeagPhantomsSettings
1010

1111

1212
class LicensesSettings(BaseCustomSettings):
1313
# ITIS - VIP
1414
LICENSES_ITIS_VIP: Annotated[
1515
ItisVipSettings | None,
1616
Field(
17-
description="Settings for VIP license models",
17+
description="Settings for VIP licensed models",
1818
json_schema_extra={"auto_default_from_env": True},
1919
),
2020
]
@@ -23,6 +23,15 @@ class LicensesSettings(BaseCustomSettings):
2323
days=1
2424
)
2525

26+
# SPEAG - PHANTOMS
27+
LICENSES_SPEAG_PHANTOMS: Annotated[
28+
SpeagPhantomsSettings | None,
29+
Field(
30+
description="Settings for SPEAG licensed phantoms",
31+
json_schema_extra={"auto_default_from_env": True},
32+
),
33+
]
34+
2635
# other licensed resources come here ...
2736

2837

0 commit comments

Comments
 (0)