Skip to content

Commit 9a00aa7

Browse files
🐛 Add legacy tasks to webserver openapi specs (#7543)
1 parent eeb6a1c commit 9a00aa7

File tree

4 files changed

+134
-11
lines changed

4 files changed

+134
-11
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# pylint: disable=redefined-outer-name
2+
# pylint: disable=unused-argument
3+
# pylint: disable=unused-variable
4+
# pylint: disable=too-many-arguments
5+
6+
7+
from typing import Annotated
8+
9+
from fastapi import APIRouter, Depends, status
10+
from models_library.generics import Envelope
11+
from servicelib.aiohttp.long_running_tasks._routes import _PathParam
12+
from servicelib.long_running_tasks._models import TaskGet, TaskStatus
13+
from simcore_service_webserver._meta import API_VTAG
14+
15+
router = APIRouter(
16+
prefix=f"/{API_VTAG}/tasks-legacy",
17+
tags=[
18+
"long-running-tasks-legacy",
19+
],
20+
)
21+
22+
23+
@router.get(
24+
"",
25+
response_model=Envelope[list[TaskGet]],
26+
name="list_tasks",
27+
description="Lists all long running tasks",
28+
)
29+
def list_tasks(): ...
30+
31+
32+
@router.get(
33+
"/{task_id}",
34+
response_model=Envelope[TaskStatus],
35+
name="get_task_status",
36+
description="Retrieves the status of a task",
37+
)
38+
def get_task_status(
39+
_path_params: Annotated[_PathParam, Depends()],
40+
): ...
41+
42+
43+
@router.delete(
44+
"/{task_id}",
45+
name="cancel_and_delete_task",
46+
description="Cancels and deletes a task",
47+
status_code=status.HTTP_204_NO_CONTENT,
48+
)
49+
def cancel_and_delete_task(
50+
_path_params: Annotated[_PathParam, Depends()],
51+
): ...
52+
53+
54+
@router.get(
55+
"/{task_id}/result",
56+
name="get_task_result",
57+
description="Retrieves the result of a task",
58+
)
59+
def get_task_result(
60+
_path_params: Annotated[_PathParam, Depends()],
61+
): ...

api/specs/web-server/openapi.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"_exporter",
3737
"_folders",
3838
"_long_running_tasks",
39+
"_long_running_tasks_legacy",
3940
"_licensed_items",
4041
"_licensed_items_purchases",
4142
"_licensed_items_checkouts",

services/web/server/src/simcore_service_webserver/api/v0/openapi.yaml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3125,6 +3125,77 @@ paths:
31253125
schema:
31263126
$ref: '#/components/schemas/EnvelopedError'
31273127
description: Internal Server Error
3128+
/v0/tasks-legacy:
3129+
get:
3130+
tags:
3131+
- long-running-tasks-legacy
3132+
summary: List Tasks
3133+
description: Lists all long running tasks
3134+
operationId: list_tasks
3135+
responses:
3136+
'200':
3137+
description: Successful Response
3138+
content:
3139+
application/json:
3140+
schema:
3141+
$ref: '#/components/schemas/Envelope_list_TaskGet__'
3142+
/v0/tasks-legacy/{task_id}:
3143+
get:
3144+
tags:
3145+
- long-running-tasks-legacy
3146+
summary: Get Task Status
3147+
description: Retrieves the status of a task
3148+
operationId: get_task_status
3149+
parameters:
3150+
- name: task_id
3151+
in: path
3152+
required: true
3153+
schema:
3154+
type: string
3155+
title: Task Id
3156+
responses:
3157+
'200':
3158+
description: Successful Response
3159+
content:
3160+
application/json:
3161+
schema:
3162+
$ref: '#/components/schemas/Envelope_TaskStatus_'
3163+
delete:
3164+
tags:
3165+
- long-running-tasks-legacy
3166+
summary: Cancel And Delete Task
3167+
description: Cancels and deletes a task
3168+
operationId: cancel_and_delete_task
3169+
parameters:
3170+
- name: task_id
3171+
in: path
3172+
required: true
3173+
schema:
3174+
type: string
3175+
title: Task Id
3176+
responses:
3177+
'204':
3178+
description: Successful Response
3179+
/v0/tasks-legacy/{task_id}/result:
3180+
get:
3181+
tags:
3182+
- long-running-tasks-legacy
3183+
summary: Get Task Result
3184+
description: Retrieves the result of a task
3185+
operationId: get_task_result
3186+
parameters:
3187+
- name: task_id
3188+
in: path
3189+
required: true
3190+
schema:
3191+
type: string
3192+
title: Task Id
3193+
responses:
3194+
'200':
3195+
description: Successful Response
3196+
content:
3197+
application/json:
3198+
schema: {}
31283199
/v0/catalog/licensed-items:
31293200
get:
31303201
tags:

services/web/server/tests/unit/with_dbs/03/test__openapi_specs.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from pytest_simcore.helpers.monkeypatch_envs import setenvs_from_dict
1414
from pytest_simcore.helpers.typing_env import EnvVarsDict
1515
from pytest_simcore.openapi_specs import Entrypoint
16-
from simcore_service_webserver._meta import API_VTAG
1716
from simcore_service_webserver.application import create_application
1817
from simcore_service_webserver.application_settings import get_application_settings
1918
from simcore_service_webserver.rest._utils import get_openapi_specs_path
@@ -76,16 +75,7 @@ def test_app_named_resources_against_openapi_specs(
7675
openapi_specs_entrypoints: set[Entrypoint],
7776
app_rest_entrypoints: set[Entrypoint],
7877
):
79-
# remove task-legacy routes. These should not be exposed.
80-
# this test compares directly against the openapi specs. In future it would be
81-
# cleaner to compare against the fastapi app entry points in specs and
82-
# avoid including the endpoints there
83-
required_entry_points = {
84-
e
85-
for e in app_rest_entrypoints
86-
if not e.path.startswith(f"/{API_VTAG}/tasks-legacy")
87-
}
88-
assert required_entry_points == openapi_specs_entrypoints
78+
assert app_rest_entrypoints == openapi_specs_entrypoints
8979

9080
# NOTE: missing here is:
9181
# - input schemas (path, query and body)

0 commit comments

Comments
 (0)