Skip to content

Commit 9a49b3a

Browse files
authored
Merge branch 'master' into enh/new-batch-get-services
2 parents a48e10b + 6834382 commit 9a49b3a

File tree

22 files changed

+362
-82
lines changed

22 files changed

+362
-82
lines changed

.github/workflows/ci-pact-master.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,5 @@ jobs:
3737
make devenv
3838
source .venv/bin/activate
3939
cd services/api-server
40+
make install-ci
4041
make test-pacts

api/specs/web-server/_storage.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from uuid import UUID
99

1010
from fastapi import APIRouter, Depends, Query, status
11-
from fastapi_pagination.cursor import CursorPage
1211
from models_library.api_schemas_storage.storage_schemas import (
1312
FileLocation,
1413
FileMetaDataGet,
@@ -32,6 +31,7 @@
3231
from models_library.projects_nodes_io import LocationID
3332
from models_library.users import UserID
3433
from pydantic import AnyUrl, ByteSize
34+
from servicelib.fastapi.rest_pagination import CustomizedPathsCursorPage
3535
from simcore_service_webserver._meta import API_VTAG
3636
from simcore_service_webserver.storage.schemas import DatasetMetaData, FileMetaData
3737

@@ -59,7 +59,7 @@ async def list_storage_locations():
5959

6060
@router.get(
6161
"/storage/locations/{location_id}/paths",
62-
response_model=CursorPage[PathMetaDataGet],
62+
response_model=CustomizedPathsCursorPage[PathMetaDataGet],
6363
)
6464
async def list_storage_paths(
6565
_path: Annotated[StorageLocationPathParams, Depends()],

packages/models-library/src/models_library/api_schemas_storage/storage_schemas.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from datetime import datetime
1010
from enum import Enum
1111
from pathlib import Path
12-
from typing import Annotated, Any, Literal, Self, TypeAlias
12+
from typing import Annotated, Any, Final, Literal, Self, TypeAlias
1313
from uuid import UUID
1414

1515
from pydantic import (
@@ -404,6 +404,10 @@ class SoftCopyBody(BaseModel):
404404
link_id: SimcoreS3FileID
405405

406406

407+
DEFAULT_NUMBER_OF_PATHS_PER_PAGE: Final[int] = 50
408+
MAX_NUMBER_OF_PATHS_PER_PAGE: Final[int] = 1000
409+
410+
407411
class PathMetaDataGet(BaseModel):
408412
path: Annotated[Path, Field(description="the path to the current path")]
409413
display_path: Annotated[

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

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
from datetime import datetime
22
from pathlib import Path
3-
from typing import Any
3+
from typing import Annotated, Any
44

5-
from pydantic import BaseModel
5+
from models_library.api_schemas_storage.storage_schemas import (
6+
DEFAULT_NUMBER_OF_PATHS_PER_PAGE,
7+
MAX_NUMBER_OF_PATHS_PER_PAGE,
8+
)
9+
from pydantic import BaseModel, Field
610

711
from ..api_schemas_rpc_async_jobs.async_jobs import (
812
AsyncJobGet,
@@ -13,7 +17,9 @@
1317
from ..api_schemas_storage.data_export_async_jobs import DataExportTaskStartInput
1418
from ..progress_bar import ProgressReport
1519
from ..projects_nodes_io import LocationID, StorageFileID
16-
from ..rest_pagination import CursorQueryParameters
20+
from ..rest_pagination import (
21+
CursorQueryParameters,
22+
)
1723
from ._base import InputSchema, OutputSchema
1824

1925

@@ -24,6 +30,15 @@ class StorageLocationPathParams(BaseModel):
2430
class ListPathsQueryParams(InputSchema, CursorQueryParameters):
2531
file_filter: Path | None = None
2632

33+
size: Annotated[
34+
int,
35+
Field(
36+
description="maximum number of items to return (pagination)",
37+
ge=1,
38+
lt=MAX_NUMBER_OF_PATHS_PER_PAGE,
39+
),
40+
] = DEFAULT_NUMBER_OF_PATHS_PER_PAGE
41+
2742

2843
class DataExportPost(InputSchema):
2944
paths: list[StorageFileID]
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from typing import TypeAlias, TypeVar
2+
3+
from fastapi import Query
4+
from fastapi_pagination.cursor import CursorPage # type: ignore[import-not-found]
5+
from fastapi_pagination.customization import ( # type: ignore[import-not-found]
6+
CustomizedPage,
7+
UseParamsFields,
8+
)
9+
from models_library.api_schemas_storage.storage_schemas import (
10+
DEFAULT_NUMBER_OF_PATHS_PER_PAGE,
11+
MAX_NUMBER_OF_PATHS_PER_PAGE,
12+
)
13+
14+
_T = TypeVar("_T")
15+
16+
CustomizedPathsCursorPage = CustomizedPage[
17+
CursorPage[_T],
18+
# Customizes the maximum value to fit frontend needs
19+
UseParamsFields(
20+
size=Query(
21+
DEFAULT_NUMBER_OF_PATHS_PER_PAGE,
22+
ge=1,
23+
le=MAX_NUMBER_OF_PATHS_PER_PAGE,
24+
description="Page size",
25+
)
26+
),
27+
]
28+
CustomizedPathsCursorPageParams: TypeAlias = CustomizedPathsCursorPage.__params_type__ # type: ignore

services/api-server/openapi.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -805,9 +805,9 @@
805805
"required": false,
806806
"schema": {
807807
"type": "integer",
808-
"maximum": 100,
808+
"maximum": 50,
809809
"minimum": 1,
810-
"default": 50,
810+
"default": 20,
811811
"title": "Limit"
812812
}
813813
},
@@ -3352,9 +3352,9 @@
33523352
"required": false,
33533353
"schema": {
33543354
"type": "integer",
3355-
"maximum": 100,
3355+
"maximum": 50,
33563356
"minimum": 1,
3357-
"default": 50,
3357+
"default": 20,
33583358
"title": "Limit"
33593359
}
33603360
},
@@ -4164,9 +4164,9 @@
41644164
"required": false,
41654165
"schema": {
41664166
"type": "integer",
4167-
"maximum": 100,
4167+
"maximum": 50,
41684168
"minimum": 1,
4169-
"default": 50,
4169+
"default": 20,
41704170
"title": "Limit"
41714171
}
41724172
},
@@ -5351,9 +5351,9 @@
53515351
"required": false,
53525352
"schema": {
53535353
"type": "integer",
5354-
"maximum": 100,
5354+
"maximum": 50,
53555355
"minimum": 1,
5356-
"default": 50,
5356+
"default": 20,
53575357
"title": "Limit"
53585358
}
53595359
},
@@ -5648,9 +5648,9 @@
56485648
"required": false,
56495649
"schema": {
56505650
"type": "integer",
5651-
"maximum": 100,
5651+
"maximum": 50,
56525652
"minimum": 1,
5653-
"default": 50,
5653+
"default": 20,
56545654
"title": "Limit"
56555655
}
56565656
},

services/api-server/src/simcore_service_api_server/models/pagination.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
""" Overrides models in fastapi_pagination
1+
"""Overrides models in fastapi_pagination
22
33
Usage:
44
from fastapi_pagination.api import create_page
@@ -11,7 +11,6 @@
1111

1212
from fastapi import Query
1313
from fastapi_pagination.customization import CustomizedPage, UseName, UseParamsFields
14-
from fastapi_pagination.limit_offset import LimitOffsetParams as _LimitOffsetParams
1514
from fastapi_pagination.links import LimitOffsetPage as _LimitOffsetPage
1615
from models_library.rest_pagination import (
1716
DEFAULT_NUMBER_OF_ITEMS_PER_PAGE,
@@ -43,7 +42,7 @@
4342
UseName(name="Page"),
4443
]
4544

46-
PaginationParams: TypeAlias = _LimitOffsetParams
45+
PaginationParams: TypeAlias = Page.__params_type__ # type: ignore
4746

4847

4948
class OnePage(BaseModel, Generic[T]):

services/api-server/tests/unit/pact_broker/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def mock_get_current_identity() -> Identity:
7676

7777

7878
@pytest.fixture()
79-
def run_test_server(
79+
def running_test_server_url(
8080
app: FastAPI,
8181
):
8282
"""
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
{
2+
"consumer": {
3+
"name": "Sim4Life"
4+
},
5+
"provider": {
6+
"name": "OsparcApiServerCheckoutRelease"
7+
},
8+
"interactions": [
9+
{
10+
"description": "Checkout one license",
11+
"request": {
12+
"method": "POST",
13+
"path": "/v0/wallets/35/licensed-items/99580844-77fa-41bb-ad70-02dfaf1e3965/checkout",
14+
"headers": {
15+
"Accept": "application/json",
16+
"Content-Type": "application/json"
17+
},
18+
"body": {
19+
"number_of_seats": 1,
20+
"service_run_id": "1740149365_21a9352a-1d46-41f9-9a9b-42ac888f5afb"
21+
}
22+
},
23+
"response": {
24+
"status": 200,
25+
"headers": {
26+
"Content-Length": "294",
27+
"Content-Type": "application/json",
28+
"Server": "uvicorn"
29+
},
30+
"body": {
31+
"key": "MODEL_IX_HEAD",
32+
"licensed_item_checkout_id": "25262183-392c-4268-9311-3c4256c46012",
33+
"licensed_item_id": "99580844-77fa-41bb-ad70-02dfaf1e3965",
34+
"num_of_seats": 1,
35+
"product_name": "s4l",
36+
"started_at": "2025-02-21T15:04:47.673828Z",
37+
"stopped_at": null,
38+
"user_id": 425,
39+
"version": "1.0.0",
40+
"wallet_id": 35
41+
}
42+
}
43+
},
44+
{
45+
"description": "Release item",
46+
"request": {
47+
"method": "POST",
48+
"path": "/v0/licensed-items/99580844-77fa-41bb-ad70-02dfaf1e3965/checked-out-items/25262183-392c-4268-9311-3c4256c46012/release",
49+
"headers": {
50+
"Accept": "application/json",
51+
"Content-Type": "application/json"
52+
}
53+
},
54+
"response": {
55+
"status": 200,
56+
"headers": {
57+
"Content-Length": "319",
58+
"Content-Type": "application/json",
59+
"Server": "uvicorn"
60+
},
61+
"body": {
62+
"key": "MODEL_IX_HEAD",
63+
"licensed_item_checkout_id": "25262183-392c-4268-9311-3c4256c46012",
64+
"licensed_item_id": "99580844-77fa-41bb-ad70-02dfaf1e3965",
65+
"num_of_seats": 1,
66+
"product_name": "s4l",
67+
"started_at": "2025-02-21T15:04:47.673828Z",
68+
"stopped_at": "2025-02-21T15:04:47.901169Z",
69+
"user_id": 425,
70+
"version": "1.0.0",
71+
"wallet_id": 35
72+
}
73+
}
74+
}
75+
],
76+
"metadata": {
77+
"pactSpecification": {
78+
"version": "3.0.0"
79+
}
80+
}
81+
}

services/api-server/tests/unit/pact_broker/pacts/05_licensed_items.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"consumer": {
3-
"name": "XOsparcApiClient"
3+
"name": "Sim4Life"
44
},
55
"provider": {
6-
"name": "OsparcApiProvider"
6+
"name": "OsparcApiServerLicensedItems"
77
},
88
"interactions": [
99
{

0 commit comments

Comments
 (0)