Skip to content

Commit 100aaae

Browse files
committed
merge master into 7199-create-storage-workhorse-mode
2 parents 31aeeb2 + e35a13f commit 100aaae

File tree

80 files changed

+2182
-1103
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+2182
-1103
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Makefile @pcrespov @sanderegg
3636
/services/payments/ @pcrespov @matusdrobuliak66
3737
/services/resource-usage-tracker/ @matusdrobuliak66
3838
/services/static-webserver/ @GitHK
39-
/services/static-webserver/client/ @jsaq007 @odeimaiz @ignapas
39+
/services/static-webserver/client/ @odeimaiz
4040
/services/storage/ @sanderegg
4141
/services/web/server/ @pcrespov @sanderegg @GitHK @matusdrobuliak66
4242
/tests/e2e-frontend/ @odeimaiz

api/specs/web-server/_licensed_items.py

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99
from typing import Annotated
1010

1111
from _common import as_query
12-
from fastapi import APIRouter, Depends, status
12+
from fastapi import APIRouter, Depends
1313
from models_library.api_schemas_webserver.licensed_items import LicensedItemRestGet
14-
from models_library.generics import Envelope
14+
from models_library.api_schemas_webserver.licensed_items_purchases import (
15+
LicensedItemPurchaseGet,
16+
)
1517
from models_library.rest_error import EnvelopedError
1618
from models_library.rest_pagination import Page
1719
from simcore_service_webserver._meta import API_VTAG
@@ -46,19 +48,9 @@ async def list_licensed_items(
4648
...
4749

4850

49-
@router.get(
50-
"/catalog/licensed-items/{licensed_item_id}",
51-
response_model=Envelope[LicensedItemRestGet],
52-
)
53-
async def get_licensed_item(
54-
_path: Annotated[LicensedItemsPathParams, Depends()],
55-
):
56-
...
57-
58-
5951
@router.post(
6052
"/catalog/licensed-items/{licensed_item_id}:purchase",
61-
status_code=status.HTTP_204_NO_CONTENT,
53+
response_model=LicensedItemPurchaseGet,
6254
)
6355
async def purchase_licensed_item(
6456
_path: Annotated[LicensedItemsPathParams, Depends()],

api/specs/web-server/_products.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
from models_library.api_schemas_webserver.product import (
1212
GenerateInvitation,
1313
GetCreditPrice,
14-
GetProduct,
1514
InvitationGenerated,
15+
ProductGet,
16+
ProductUIGet,
1617
UpdateProductTemplate,
1718
)
1819
from models_library.generics import Envelope
@@ -40,7 +41,8 @@ async def get_current_product_price():
4041

4142
@router.get(
4243
"/products/{product_name}",
43-
response_model=Envelope[GetProduct],
44+
response_model=Envelope[ProductGet],
45+
description="NOTE: `/products/current` is used to define current project w/o naming it",
4446
tags=[
4547
"po",
4648
],
@@ -49,6 +51,14 @@ async def get_product(_params: Annotated[_ProductsRequestParams, Depends()]):
4951
...
5052

5153

54+
@router.get(
55+
"/products/current/ui",
56+
response_model=Envelope[ProductUIGet],
57+
)
58+
async def get_current_product_ui():
59+
...
60+
61+
5262
@router.put(
5363
"/products/{product_name}/templates/{template_id}",
5464
status_code=status.HTTP_204_NO_CONTENT,

packages/models-library/src/models_library/api_schemas_resource_usage_tracker/licensed_items_checkouts.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from datetime import datetime
22
from typing import NamedTuple
33

4-
from models_library.licenses import LicensedItemID
4+
from models_library.licenses import LicensedItemID, LicensedItemKey, LicensedItemVersion
55
from models_library.products import ProductName
66
from models_library.resource_tracker_licensed_items_checkouts import (
77
LicensedItemCheckoutID,
@@ -15,6 +15,8 @@
1515
class LicensedItemCheckoutGet(BaseModel):
1616
licensed_item_checkout_id: LicensedItemCheckoutID
1717
licensed_item_id: LicensedItemID
18+
key: LicensedItemKey
19+
version: LicensedItemVersion
1820
wallet_id: WalletID
1921
user_id: UserID
2022
user_email: str
@@ -30,6 +32,8 @@ class LicensedItemCheckoutGet(BaseModel):
3032
{
3133
"licensed_item_checkout_id": "beb16d18-d57d-44aa-a638-9727fa4a72ef",
3234
"licensed_item_id": "303942ef-6d31-4ba8-afbe-dbb1fce2a953",
35+
"key": "Duke",
36+
"version": "1.0.0",
3337
"wallet_id": 1,
3438
"user_id": 1,
3539
"user_email": "[email protected]",

packages/models-library/src/models_library/api_schemas_resource_usage_tracker/licensed_items_purchases.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from decimal import Decimal
33
from typing import NamedTuple
44

5-
from models_library.licenses import LicensedItemID
5+
from models_library.licenses import LicensedItemID, LicensedItemKey, LicensedItemVersion
66
from models_library.products import ProductName
77
from models_library.resource_tracker import PricingUnitCostId
88
from models_library.resource_tracker_licensed_items_purchases import (
@@ -17,6 +17,8 @@ class LicensedItemPurchaseGet(BaseModel):
1717
licensed_item_purchase_id: LicensedItemPurchaseID
1818
product_name: ProductName
1919
licensed_item_id: LicensedItemID
20+
key: LicensedItemKey
21+
version: LicensedItemVersion
2022
wallet_id: WalletID
2123
wallet_name: str
2224
pricing_unit_cost_id: PricingUnitCostId
@@ -36,6 +38,8 @@ class LicensedItemPurchaseGet(BaseModel):
3638
"licensed_item_purchase_id": "beb16d18-d57d-44aa-a638-9727fa4a72ef",
3739
"product_name": "osparc",
3840
"licensed_item_id": "303942ef-6d31-4ba8-afbe-dbb1fce2a953",
41+
"key": "Duke",
42+
"version": "1.0.0",
3943
"wallet_id": 1,
4044
"wallet_name": "My Wallet",
4145
"pricing_unit_cost_id": 1,

packages/models-library/src/models_library/api_schemas_webserver/licensed_items.py

Lines changed: 44 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
FeaturesDict,
1212
LicensedItem,
1313
LicensedItemID,
14+
LicensedItemKey,
15+
LicensedItemVersion,
1416
LicensedResourceType,
1517
)
1618
from ._base import OutputSchema
@@ -20,9 +22,11 @@
2022

2123
class LicensedItemRpcGet(BaseModel):
2224
licensed_item_id: LicensedItemID
25+
key: LicensedItemKey
26+
version: LicensedItemVersion
2327
display_name: str
2428
licensed_resource_type: LicensedResourceType
25-
licensed_resource_data: dict[str, Any]
29+
licensed_resources: list[dict[str, Any]]
2630
pricing_plan_id: PricingPlanId
2731
created_at: datetime
2832
modified_at: datetime
@@ -32,9 +36,11 @@ class LicensedItemRpcGet(BaseModel):
3236
"examples": [
3337
{
3438
"licensed_item_id": "0362b88b-91f8-4b41-867c-35544ad1f7a1",
39+
"key": "Duke",
40+
"version": "1.0.0",
3541
"display_name": "best-model",
3642
"licensed_resource_type": f"{LicensedResourceType.VIP_MODEL}",
37-
"licensed_resource_data": cast(JsonDict, VIP_DETAILS_EXAMPLE),
43+
"licensed_resources": [cast(JsonDict, VIP_DETAILS_EXAMPLE)],
3844
"pricing_plan_id": "15",
3945
"created_at": "2024-12-12 09:59:26.422140",
4046
"modified_at": "2024-12-12 09:59:26.422140",
@@ -58,24 +64,28 @@ class _ItisVipRestData(OutputSchema):
5864
thumbnail: str
5965
features: FeaturesDict # NOTE: here there is a bit of coupling with domain model
6066
doi: str | None
67+
license_version: str
6168

6269

6370
class _ItisVipResourceRestData(OutputSchema):
64-
category_id: IDStr
65-
category_display: str
66-
category_icon: HttpUrl | None = None # NOTE: Placeholder until provide @odeimaiz
6771
source: _ItisVipRestData
68-
terms_of_use_url: HttpUrl | None = None # NOTE: Placeholder until provided @mguidon
6972

7073

7174
class LicensedItemRestGet(OutputSchema):
7275
licensed_item_id: LicensedItemID
76+
key: LicensedItemKey
77+
version: LicensedItemVersion
78+
7379
display_name: str
74-
# NOTE: to put here a discriminator we have to embed it one more layer
7580
licensed_resource_type: LicensedResourceType
76-
licensed_resource_data: _ItisVipResourceRestData
81+
licensed_resources: list[_ItisVipResourceRestData]
7782
pricing_plan_id: PricingPlanId
7883

84+
category_id: IDStr
85+
category_display: str
86+
category_icon: HttpUrl | None = None # NOTE: Placeholder until provide @odeimaiz
87+
terms_of_use_url: HttpUrl | None = None # NOTE: Placeholder until provided @mguidon
88+
7989
created_at: datetime
8090
modified_at: datetime
8191

@@ -86,17 +96,21 @@ def _update_json_schema_extra(schema: JsonDict) -> None:
8696
"examples": [
8797
{
8898
"licensedItemId": "0362b88b-91f8-4b41-867c-35544ad1f7a1",
99+
"key": "Duke",
100+
"version": "1.0.0",
89101
"displayName": "my best model",
90102
"licensedResourceType": f"{LicensedResourceType.VIP_MODEL}",
91-
"licensedResourceData": cast(
92-
JsonDict,
93-
{
94-
"categoryId": "HumanWholeBody",
95-
"categoryDisplay": "Humans",
96-
"source": {**VIP_DETAILS_EXAMPLE, "doi": doi},
97-
},
98-
),
103+
"licensedResources": [
104+
cast(
105+
JsonDict,
106+
{
107+
"source": {**VIP_DETAILS_EXAMPLE, "doi": doi},
108+
},
109+
)
110+
],
99111
"pricingPlanId": "15",
112+
"categoryId": "HumanWholeBody",
113+
"categoryDisplay": "Humans",
100114
"createdAt": "2024-12-12 09:59:26.422140",
101115
"modifiedAt": "2024-12-12 09:59:26.422140",
102116
}
@@ -114,6 +128,8 @@ def from_domain_model(cls, item: LicensedItem) -> Self:
114128
**item.model_dump(
115129
include={
116130
"licensed_item_id",
131+
"key",
132+
"version",
117133
"display_name",
118134
"licensed_resource_type",
119135
"pricing_plan_id",
@@ -122,9 +138,18 @@ def from_domain_model(cls, item: LicensedItem) -> Self:
122138
},
123139
exclude_unset=True,
124140
),
125-
"licensed_resource_data": {
126-
**item.licensed_resource_data,
127-
},
141+
"licensed_resources": [
142+
_ItisVipResourceRestData(**x)
143+
for x in sorted(
144+
item.licensed_resources,
145+
key=lambda x: datetime.strptime(
146+
x["source"]["features"]["date"], "%Y-%m-%d"
147+
),
148+
reverse=True,
149+
)
150+
],
151+
"category_id": item.licensed_resources[0]["category_id"],
152+
"category_display": item.licensed_resources[0]["category_display"],
128153
}
129154
)
130155

packages/models-library/src/models_library/api_schemas_webserver/licensed_items_checkouts.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from models_library.emails import LowerCaseEmailStr
55
from pydantic import BaseModel, ConfigDict, PositiveInt
66

7-
from ..licenses import LicensedItemID
7+
from ..licenses import LicensedItemID, LicensedItemKey, LicensedItemVersion
88
from ..products import ProductName
99
from ..resource_tracker_licensed_items_checkouts import LicensedItemCheckoutID
1010
from ..users import UserID
@@ -17,6 +17,8 @@
1717
class LicensedItemCheckoutRpcGet(BaseModel):
1818
licensed_item_checkout_id: LicensedItemCheckoutID
1919
licensed_item_id: LicensedItemID
20+
key: LicensedItemKey
21+
version: LicensedItemVersion
2022
wallet_id: WalletID
2123
user_id: UserID
2224
product_name: ProductName
@@ -29,6 +31,8 @@ class LicensedItemCheckoutRpcGet(BaseModel):
2931
{
3032
"licensed_item_checkout_id": "633ef980-6f3e-4b1a-989a-bd77bf9a5d6b",
3133
"licensed_item_id": "0362b88b-91f8-4b41-867c-35544ad1f7a1",
34+
"key": "Duke",
35+
"version": "1.0.0",
3236
"wallet_id": 6,
3337
"user_id": 27845,
3438
"product_name": "osparc",
@@ -52,6 +56,8 @@ class LicensedItemCheckoutRpcGetPage(NamedTuple):
5256
class LicensedItemCheckoutRestGet(OutputSchema):
5357
licensed_item_checkout_id: LicensedItemCheckoutID
5458
licensed_item_id: LicensedItemID
59+
key: str
60+
version: str
5561
wallet_id: WalletID
5662
user_id: UserID
5763
user_email: LowerCaseEmailStr

packages/models-library/src/models_library/api_schemas_webserver/licensed_items_purchases.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from models_library.emails import LowerCaseEmailStr
66
from pydantic import PositiveInt
77

8-
from ..licenses import LicensedItemID
8+
from ..licenses import LicensedItemID, LicensedItemKey, LicensedItemVersion
99
from ..products import ProductName
1010
from ..resource_tracker import PricingUnitCostId
1111
from ..resource_tracker_licensed_items_purchases import LicensedItemPurchaseID
@@ -18,6 +18,8 @@ class LicensedItemPurchaseGet(OutputSchema):
1818
licensed_item_purchase_id: LicensedItemPurchaseID
1919
product_name: ProductName
2020
licensed_item_id: LicensedItemID
21+
key: LicensedItemKey
22+
version: LicensedItemVersion
2123
wallet_id: WalletID
2224
pricing_unit_cost_id: PricingUnitCostId
2325
pricing_unit_cost: Decimal

0 commit comments

Comments
 (0)