11import logging
22from typing import Annotated , Any
33
4+ from common_library .changelog import create_route_description
45from fastapi import APIRouter , Depends , FastAPI , status
56from models_library .api_schemas_long_running_tasks .base import TaskProgress
67from models_library .api_schemas_long_running_tasks .tasks import (
1516from models_library .products import ProductName
1617from models_library .users import UserID
1718from servicelib .fastapi .dependencies import get_app
18- from simcore_service_api_server .models .schemas .tasks import ApiServerEnvelope
1919
20+ from ...models .schemas .base import ApiServerEnvelope
2021from ...models .schemas .errors import ErrorGet
2122from ...services_rpc .async_jobs import AsyncJobClient
2223from ..dependencies .authentication import get_current_user_id , get_product_name
2324from ..dependencies .tasks import get_async_jobs_client
25+ from ._constants import (
26+ FMSG_CHANGELOG_NEW_IN_VERSION ,
27+ create_route_description ,
28+ )
2429
2530router = APIRouter ()
2631_logger = logging .getLogger (__name__ )
@@ -43,8 +48,16 @@ def _get_job_id_data(user_id: UserID, product_name: ProductName) -> AsyncJobName
4348 response_model = ApiServerEnvelope [list [TaskGet ]],
4449 responses = _DEFAULT_TASK_STATUS_CODES ,
4550 status_code = status .HTTP_200_OK ,
51+ name = "list_tasks" ,
52+ description = create_route_description (
53+ base = "List all tasks" ,
54+ changelog = [
55+ FMSG_CHANGELOG_NEW_IN_VERSION .format ("0.10-rc1" ),
56+ ],
57+ ),
58+ include_in_schema = False , # TO BE RELEASED in 0.10-rc1
4659)
47- async def get_async_jobs (
60+ async def list_tasks (
4861 app : Annotated [FastAPI , Depends (get_app )],
4962 user_id : Annotated [UserID , Depends (get_current_user_id )],
5063 product_name : Annotated [ProductName , Depends (get_product_name )],
@@ -60,13 +73,11 @@ async def get_async_jobs(
6073 task_id = f"{ job .job_id } " ,
6174 task_name = job .job_name ,
6275 status_href = app_router .url_path_for (
63- "get_async_job_status" , task_id = f"{ job .job_id } "
64- ),
65- abort_href = app_router .url_path_for (
66- "cancel_async_job" , task_id = f"{ job .job_id } "
76+ "get_task_status" , task_id = f"{ job .job_id } "
6777 ),
78+ abort_href = app_router .url_path_for ("cancel_task" , task_id = f"{ job .job_id } " ),
6879 result_href = app_router .url_path_for (
69- "get_async_job_result " , task_id = f"{ job .job_id } "
80+ "get_task_result " , task_id = f"{ job .job_id } "
7081 ),
7182 )
7283 for job in user_async_jobs
@@ -77,11 +88,18 @@ async def get_async_jobs(
7788@router .get (
7889 "/{task_id}" ,
7990 response_model = TaskStatus ,
80- name = "get_async_job_status " ,
91+ name = "get_task_status " ,
8192 responses = _DEFAULT_TASK_STATUS_CODES ,
8293 status_code = status .HTTP_200_OK ,
94+ description = create_route_description (
95+ base = "Get task status" ,
96+ changelog = [
97+ FMSG_CHANGELOG_NEW_IN_VERSION .format ("0.10-rc1" ),
98+ ],
99+ ),
100+ include_in_schema = False , # TO BE RELEASED in 0.10-rc1
83101)
84- async def get_async_job_status (
102+ async def get_task_status (
85103 task_id : AsyncJobId ,
86104 user_id : Annotated [UserID , Depends (get_current_user_id )],
87105 product_name : Annotated [ProductName , Depends (get_product_name )],
@@ -104,10 +122,17 @@ async def get_async_job_status(
104122@router .post (
105123 "/{task_id}:cancel" ,
106124 status_code = status .HTTP_204_NO_CONTENT ,
107- name = "cancel_async_job " ,
125+ name = "cancel_task " ,
108126 responses = _DEFAULT_TASK_STATUS_CODES ,
127+ description = create_route_description (
128+ base = "Cancel task" ,
129+ changelog = [
130+ FMSG_CHANGELOG_NEW_IN_VERSION .format ("0.10-rc1" ),
131+ ],
132+ ),
133+ include_in_schema = False , # TO BE RELEASED in 0.10-rc1
109134)
110- async def cancel_async_job (
135+ async def cancel_task (
111136 task_id : AsyncJobId ,
112137 user_id : Annotated [UserID , Depends (get_current_user_id )],
113138 product_name : Annotated [ProductName , Depends (get_product_name )],
@@ -122,7 +147,7 @@ async def cancel_async_job(
122147@router .get (
123148 "/{task_id}/result" ,
124149 response_model = TaskResult ,
125- name = "get_async_job_result " ,
150+ name = "get_task_result " ,
126151 responses = {
127152 status .HTTP_404_NOT_FOUND : {
128153 "description" : "Task result not found" ,
@@ -135,8 +160,15 @@ async def cancel_async_job(
135160 ** _DEFAULT_TASK_STATUS_CODES ,
136161 },
137162 status_code = status .HTTP_200_OK ,
163+ description = create_route_description (
164+ base = "Get task result" ,
165+ changelog = [
166+ FMSG_CHANGELOG_NEW_IN_VERSION .format ("0.10-rc1" ),
167+ ],
168+ ),
169+ include_in_schema = False , # TO BE RELEASED in 0.10-rc1
138170)
139- async def get_async_job_result (
171+ async def get_task_result (
140172 task_id : AsyncJobId ,
141173 user_id : Annotated [UserID , Depends (get_current_user_id )],
142174 product_name : Annotated [ProductName , Depends (get_product_name )],
0 commit comments