Skip to content

task_models

CompoundTask

Bases: _BaseTask

A CompoundTask object must include both executable_init and executable attributes, and it may include the meta_init and meta attributes.

Source code in src/fractal_task_tools/task_models.py
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
class CompoundTask(_BaseTask):
    """
    A `CompoundTask` object must include both `executable_init` and
    `executable` attributes, and it may include the `meta_init` and `meta`
    attributes.
    """

    executable_init: str
    meta_init: Optional[dict[str, Any]] = None
    type: Literal["compound"] = "compound"

    @property
    def executable_non_parallel(self) -> str:
        return self.executable_init

    @property
    def meta_non_parallel(self) -> Optional[dict[str, Any]]:
        return self.meta_init

    @property
    def executable_parallel(self) -> str:
        return self.executable

    @property
    def meta_parallel(self) -> Optional[dict[str, Any]]:
        return self.meta

ConverterCompoundTask

Bases: _BaseTask

A ConverterCompoundTask task is the same as a CompoundTask, but it is executed differently in the Fractal backend.

Source code in src/fractal_task_tools/task_models.py
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
class ConverterCompoundTask(_BaseTask):
    """
    A `ConverterCompoundTask` task is the same as a `CompoundTask`, but it
    is executed differently in the Fractal backend.
    """

    executable_init: str
    meta_init: Optional[dict[str, Any]] = None
    type: Literal["converter_compound"] = "converter_compound"

    @property
    def executable_non_parallel(self) -> str:
        return self.executable_init

    @property
    def meta_non_parallel(self) -> Optional[dict[str, Any]]:
        return self.meta_init

    @property
    def executable_parallel(self) -> str:
        return self.executable

    @property
    def meta_parallel(self) -> Optional[dict[str, Any]]:
        return self.meta

ConverterNonParallelTask

Bases: _BaseTask

A ConverterNonParallelTask task is the same as a NonParallelTask, but it is executed differently in the Fractal backend.

Source code in src/fractal_task_tools/task_models.py
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
class ConverterNonParallelTask(_BaseTask):
    """
    A `ConverterNonParallelTask` task is the same as a `NonParallelTask`, but
    it is executed differently in the Fractal backend.
    """

    type: Literal["converter_non_parallel"] = "converter_non_parallel"

    @property
    def executable_non_parallel(self) -> str:
        return self.executable

    @property
    def meta_non_parallel(self) -> Optional[dict[str, Any]]:
        return self.meta

    @property
    def executable_parallel(self) -> None:
        return None

    @property
    def meta_parallel(self) -> None:
        return None

NonParallelTask

Bases: _BaseTask

A NonParallelTask object must include the executable attribute, and it may include the meta attribute.

Source code in src/fractal_task_tools/task_models.py
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
class NonParallelTask(_BaseTask):
    """
    A `NonParallelTask` object must include the `executable` attribute, and it
    may include the `meta` attribute.
    """

    type: Literal["non_parallel"] = "non_parallel"

    @property
    def executable_non_parallel(self) -> str:
        return self.executable

    @property
    def meta_non_parallel(self) -> Optional[dict[str, Any]]:
        return self.meta

    @property
    def executable_parallel(self) -> None:
        return None

    @property
    def meta_parallel(self) -> None:
        return None

ParallelTask

Bases: _BaseTask

A ParallelTask object must include the executable attribute, and it may include the meta attribute.

Source code in src/fractal_task_tools/task_models.py
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
class ParallelTask(_BaseTask):
    """
    A `ParallelTask` object must include the `executable` attribute, and it may
    include the `meta` attribute.
    """

    type: Literal["parallel"] = "parallel"

    @property
    def executable_non_parallel(self) -> None:
        return None

    @property
    def meta_non_parallel(self) -> None:
        return None

    @property
    def executable_parallel(self) -> str:
        return self.executable

    @property
    def meta_parallel(self) -> Optional[dict[str, Any]]:
        return self.meta

_TaskList

Bases: RootModel

List of valid tasks, with unique names.

Note: this model is only used for validation, and then discarded. If you want to use its data, you should e.g. override the __iter__ and __getitem__ methods. See https://pydantic.dev/docs/validation/latest/concepts/models/#rootmodel-and-custom-root-types

Source code in src/fractal_task_tools/task_models.py
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
class _TaskList(RootModel):
    """
    List of valid tasks, with unique names.

    Note: this model is only used for validation, and then discarded. If you
    want to use its data, you should e.g. override the `__iter__` and
    `__getitem__` methods. See
    https://pydantic.dev/docs/validation/latest/concepts/models/#rootmodel-and-custom-root-types
    """

    root: list[_AnyTask]

    @model_validator(mode="after")
    def check_unique_names(self: Self) -> Self:
        task_names = [task.name for task in self.root]
        if len(set(task_names)) != len(task_names):
            raise ValueError(f"Task names must be unique (given: {task_names}).")