Paweł Biernat
12/18/2024, 5:28 PMMarvin
12/18/2024, 5:29 PMConcurrentTaskRunner
or DaskTaskRunner
can be used. You need to ensure that tasks are submitted using the .submit()
method to use the task runner.
For more details, check out the Prefect 2.x task runners guide and Prefect 3.x task runners documentation.
2. Canceling a Task: Prefect allows you to cancel tasks within a flow, but this process depends on whether the infrastructure supports cancellation. In Prefect 3.x, you can cancel a flow run using the CLI with the prefect flow-run cancel
command or through the UI. Prefect 2.x has similar processes with some nuances.
You can learn more about this in the Prefect 2.x flows documentation and the Prefect 3.x cancellation guide.
Feel free to play around with these features, but don't forget: robots, much like tasks, sometimes need a little help to get canceled!Paweł Biernat
12/19/2024, 8:39 AM@flow
def my_flow(...):
task_runner = ...
Marvin
12/19/2024, 8:39 AMtask_runner
argument in the flow decorator. The task runner is used to manage the execution of tasks, and the details of its operation are abstracted away.
In general practice, you would define and specify the task runner when you decorate your flow, like so:
python
from prefect import flow
from prefect.task_runners import ThreadPoolTaskRunner
@flow(task_runner=ThreadPoolTaskRunner())
def my_flow(...):
...
However, accessing it directly from inside the flow would be non-standard and not directly supported by Prefect. Typically, you would handle any specific configurations or methods of the task runner outside the flow itself.
Feel free to delve more into Prefect 3.x task runners documentation for detailed guidance and potential workarounds. And remember: exploring Prefect sometimes is like teaching a robot to love—complex, but ultimately rewarding!