Skip to content

Commit 6c9cae3

Browse files
author
Andrei Neagu
committed
bring back task_name
1 parent 0ed5b07 commit 6c9cae3

File tree

2 files changed

+22
-1
lines changed
  • packages/models-library/src/models_library/api_schemas_long_running_tasks
  • services/web/server/src/simcore_service_webserver/api/v0

2 files changed

+22
-1
lines changed

packages/models-library/src/models_library/api_schemas_long_running_tasks/tasks.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import urllib.parse
12
from datetime import datetime
23
from typing import Any
34

4-
from pydantic import BaseModel
5+
from pydantic import BaseModel, field_validator
56

67
from .base import TaskId, TaskProgress
78

@@ -20,6 +21,22 @@ class TaskResult(BaseModel):
2021
class TaskBase(BaseModel):
2122
task_id: TaskId
2223

24+
# NOTE: task name can always be extraced from the task_id
25+
# since it'e encoded inside it
26+
task_name: str = ""
27+
28+
@field_validator("task_name", mode="before")
29+
@classmethod
30+
def populate_task_name(cls, _, info):
31+
task_name = ""
32+
task_id = info.data.get("task_id")
33+
if task_id:
34+
parts = task_id.split(".")
35+
if len(parts) >= 1:
36+
task_name = parts[1]
37+
38+
return urllib.parse.unquote(task_name)
39+
2340

2441
class TaskGet(TaskBase):
2542
status_href: str

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16716,6 +16716,9 @@ components:
1671616716
task_id:
1671716717
type: string
1671816718
title: Task Id
16719+
task_name:
16720+
type: string
16721+
title: Task Name
1671916722
status_href:
1672016723
type: string
1672116724
title: Status Href
@@ -16728,6 +16731,7 @@ components:
1672816731
type: object
1672916732
required:
1673016733
- task_id
16734+
- task_name
1673116735
- status_href
1673216736
- result_href
1673316737
- abort_href

0 commit comments

Comments
 (0)