Skip to content

Commit 668446a

Browse files
committed
increased limit
1 parent 7870cc8 commit 668446a

File tree

3 files changed

+71
-12
lines changed

3 files changed

+71
-12
lines changed

services/storage/openapi.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,8 +1047,8 @@
10471047
"required": false,
10481048
"schema": {
10491049
"type": "integer",
1050-
"maximum": 100,
1051-
"minimum": 0,
1050+
"maximum": 1000,
1051+
"minimum": 1,
10521052
"default": 50,
10531053
"title": "Size"
10541054
}
@@ -1060,7 +1060,7 @@
10601060
"content": {
10611061
"application/json": {
10621062
"schema": {
1063-
"$ref": "#/components/schemas/CursorPage_PathMetaDataGet_"
1063+
"$ref": "#/components/schemas/CursorPage__T_Customized_PathMetaDataGet_"
10641064
}
10651065
}
10661066
}
@@ -1419,7 +1419,7 @@
14191419
],
14201420
"title": "AppStatusCheck"
14211421
},
1422-
"CursorPage_PathMetaDataGet_": {
1422+
"CursorPage__T_Customized_PathMetaDataGet_": {
14231423
"properties": {
14241424
"items": {
14251425
"items": {
@@ -1493,7 +1493,7 @@
14931493
"required": [
14941494
"items"
14951495
],
1496-
"title": "CursorPage[PathMetaDataGet]"
1496+
"title": "CursorPage[~T]Customized[PathMetaDataGet]"
14971497
},
14981498
"DatasetMetaDataGet": {
14991499
"properties": {

services/storage/src/simcore_service_storage/api/rest/_paths.py

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import logging
22
from pathlib import Path
3-
from typing import Annotated
3+
from typing import Annotated, TypeVar
44

5-
from fastapi import APIRouter, Depends
6-
from fastapi_pagination import create_page
7-
from fastapi_pagination.cursor import CursorPage, CursorParams
5+
from fastapi import APIRouter, Depends, Query
6+
from fastapi_pagination import create_page, resolve_params
7+
from fastapi_pagination.cursor import CursorPage
8+
from fastapi_pagination.customization import CustomizedPage, UseParamsFields
89
from models_library.api_schemas_storage.storage_schemas import PathMetaDataGet
910
from models_library.users import UserID
1011

@@ -19,18 +20,34 @@
1920
],
2021
)
2122

23+
T = TypeVar("T")
24+
25+
Page = CustomizedPage[
26+
CursorPage[T],
27+
# Customizes the maximum value to fit frontend needs
28+
UseParamsFields(
29+
size=Query(
30+
50,
31+
ge=1,
32+
le=1000,
33+
description="Page size",
34+
)
35+
),
36+
]
37+
2238

2339
@router.get(
2440
"/locations/{location_id}/paths",
25-
response_model=CursorPage[PathMetaDataGet],
41+
response_model=Page[PathMetaDataGet],
2642
)
2743
async def list_paths(
28-
page_params: Annotated[CursorParams, Depends()],
44+
page_params: Annotated[Page.__params_type__, Depends()],
2945
dsm: Annotated[BaseDataManager, Depends(get_data_manager)],
3046
user_id: UserID,
3147
file_filter: Path | None = None,
32-
):
48+
) -> Page[PathMetaDataGet]:
3349
"""Returns one level of files (paginated)"""
50+
page_params = resolve_params()
3451
items, next_cursor, total_number = await dsm.list_paths(
3552
user_id=user_id,
3653
file_filter=file_filter,

services/storage/tests/unit/test_handlers_paths.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,48 @@ async def test_list_paths_pagination(
203203
)
204204

205205

206+
@pytest.mark.parametrize(
207+
"project_params",
208+
[
209+
ProjectWithFilesParams(
210+
num_nodes=1,
211+
allowed_file_sizes=(TypeAdapter(ByteSize).validate_python("0b"),),
212+
workspace_files_count=1000,
213+
)
214+
],
215+
ids=str,
216+
)
217+
async def test_list_paths_pagination_large_page(
218+
initialized_app: FastAPI,
219+
client: httpx.AsyncClient,
220+
location_id: LocationID,
221+
user_id: UserID,
222+
with_random_project_with_files: tuple[
223+
dict[str, Any],
224+
dict[NodeID, dict[SimcoreS3FileID, FileIDDict]],
225+
],
226+
):
227+
project, list_of_files = with_random_project_with_files
228+
selected_node_id = NodeID(random.choice(list(project["workbench"]))) # noqa: S311
229+
selected_node_s3_keys = [
230+
Path(s3_object_id) for s3_object_id in list_of_files[selected_node_id]
231+
]
232+
workspace_file_filter = Path(project["uuid"]) / f"{selected_node_id}" / "workspace"
233+
expected_paths = _filter_and_group_paths_one_level_deeper(
234+
selected_node_s3_keys, workspace_file_filter
235+
)
236+
await _assert_list_paths(
237+
initialized_app,
238+
client,
239+
location_id,
240+
user_id,
241+
file_filter=workspace_file_filter,
242+
expected_paths=expected_paths,
243+
check_total=False,
244+
limit=1000,
245+
)
246+
247+
206248
@pytest.mark.parametrize(
207249
"project_params, num_projects",
208250
[

0 commit comments

Comments
 (0)