Skip to content

task_group

TaskGroupCreateV2Strict

Bases: TaskGroupCreateV2

A strict version of TaskGroupCreateV2, to be used for task collection.

Source code in fractal_server/app/schemas/v2/task_group.py
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
class TaskGroupCreateV2Strict(TaskGroupCreateV2):
    """
    A strict version of TaskGroupCreateV2, to be used for task collection.
    """

    path: str
    venv_path: str
    version: str
    python_version: str

    @root_validator
    def check_wheel_file(cls, values):
        origin = values.get("origin")
        wheel_path = values.get("wheel_path")
        bad_condition_1 = (
            origin == TaskGroupV2OriginEnum.WHEELFILE and wheel_path is None
        )
        bad_condition_2 = (
            origin != TaskGroupV2OriginEnum.WHEELFILE
            and wheel_path is not None
        )
        if bad_condition_1 or bad_condition_2:
            raise ValueError(f"Cannot have {origin=} and {wheel_path=}.")
        return values