Skip to content

Commit b9fab9b

Browse files
authored
Merge pull request #2384 from fractal-analytics-platform/refine-task-type-logics
Refine new task-type logics
2 parents e7bb2b1 + 9130bf1 commit b9fab9b

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

fractal_server/app/routes/api/v2/workflowtask.py

+13-2
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,22 @@ async def replace_workflowtask(
5656
)
5757

5858
# Preliminary checks
59-
if old_wftask.task_type != new_task.type:
59+
EQUIVALENT_TASK_TYPES = [
60+
{"non_parallel", "converter_non_parallel"},
61+
{"compound", "converter_compound"},
62+
]
63+
if (
64+
old_wftask.task_type != new_task.type
65+
and {old_wftask.task_type, new_task.type} not in EQUIVALENT_TASK_TYPES
66+
):
6067
raise HTTPException(
6168
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
6269
detail=(
6370
"Cannot change task type from "
6471
f"{old_wftask.task_type} to {new_task.type}."
6572
),
6673
)
74+
6775
if replace.args_non_parallel is not None and new_task.type == "parallel":
6876
raise HTTPException(
6977
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
@@ -259,7 +267,10 @@ async def update_workflowtask(
259267
"parallel."
260268
),
261269
)
262-
elif db_wf_task.task_type == "non_parallel" and (
270+
elif db_wf_task.task_type in [
271+
"non_parallel",
272+
"converter_non_parallel",
273+
] and (
263274
workflow_task_update.args_parallel is not None
264275
or workflow_task_update.meta_parallel is not None
265276
):

fractal_server/app/schemas/v2/workflowtask.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from .task import TaskImportV2
1717
from .task import TaskImportV2Legacy
1818
from .task import TaskReadV2
19+
from .task import TaskTypeType
1920

2021
RESERVED_ARGUMENTS = {"zarr_dir", "zarr_url", "zarr_urls", "init_args"}
2122

@@ -113,7 +114,7 @@ class WorkflowTaskReadV2(BaseModel):
113114

114115
type_filters: dict[str, bool]
115116

116-
task_type: str
117+
task_type: TaskTypeType
117118
task_id: int
118119
task: TaskReadV2
119120

0 commit comments

Comments
 (0)