|
17 | 17 | from taskiq.kicker import AsyncKicker
|
18 | 18 | from typing_extensions import ParamSpec
|
19 | 19 |
|
20 |
| -from taskiq_pipelines.constants import CURRENT_STEP, PIPELINE_DATA |
| 20 | +from taskiq_pipelines.constants import CURRENT_STEP, EMPTY_PARAM_NAME, PIPELINE_DATA |
21 | 21 | from taskiq_pipelines.steps import FilterStep, MapperStep, SequentialStep, parse_step
|
22 | 22 |
|
23 | 23 | _ReturnType = TypeVar("_ReturnType")
|
@@ -122,6 +122,62 @@ def call_next(
|
122 | 122 | )
|
123 | 123 | return self
|
124 | 124 |
|
| 125 | + @overload |
| 126 | + def call_after( |
| 127 | + self: "Pipeline[_FuncParams, _ReturnType]", |
| 128 | + task: Union[ |
| 129 | + AsyncKicker[Any, Coroutine[Any, Any, _T2]], |
| 130 | + AsyncTaskiqDecoratedTask[Any, Coroutine[Any, Any, _T2]], |
| 131 | + ], |
| 132 | + **additional_kwargs: Any, |
| 133 | + ) -> "Pipeline[_FuncParams, _T2]": |
| 134 | + ... |
| 135 | + |
| 136 | + @overload |
| 137 | + def call_after( |
| 138 | + self: "Pipeline[_FuncParams, _ReturnType]", |
| 139 | + task: Union[ |
| 140 | + AsyncKicker[Any, _T2], |
| 141 | + AsyncTaskiqDecoratedTask[Any, _T2], |
| 142 | + ], |
| 143 | + **additional_kwargs: Any, |
| 144 | + ) -> "Pipeline[_FuncParams, _T2]": |
| 145 | + ... |
| 146 | + |
| 147 | + def call_after( |
| 148 | + self, |
| 149 | + task: Union[ |
| 150 | + AsyncKicker[Any, Any], |
| 151 | + AsyncTaskiqDecoratedTask[Any, Any], |
| 152 | + ], |
| 153 | + **additional_kwargs: Any, |
| 154 | + ) -> Any: |
| 155 | + """ |
| 156 | + Adds sequential step. |
| 157 | +
|
| 158 | + This task will be executed right after |
| 159 | + the previous and result of the previous task |
| 160 | + is not passed to the next task. |
| 161 | +
|
| 162 | + This is equivalent to call_next(task, param_name=-1). |
| 163 | +
|
| 164 | + :param task: task to execute. |
| 165 | + :param additional_kwargs: additional kwargs to task. |
| 166 | + :return: updated pipeline. |
| 167 | + """ |
| 168 | + self.steps.append( |
| 169 | + DumpedStep( |
| 170 | + step_type=SequentialStep.step_name, |
| 171 | + step_data=SequentialStep.from_task( |
| 172 | + task=task, |
| 173 | + param_name=EMPTY_PARAM_NAME, |
| 174 | + **additional_kwargs, |
| 175 | + ).dumps(), |
| 176 | + task_id="", |
| 177 | + ), |
| 178 | + ) |
| 179 | + return self |
| 180 | + |
125 | 181 | @overload
|
126 | 182 | def map(
|
127 | 183 | self: "Pipeline[_FuncParams, _ReturnType]",
|
|
0 commit comments