Conditionally running tasks and filtering their results in Prefect 1.0 and 2.0

Summary

Running tasks conditionally and filtering results in Prefect 2.0 is now effectively the same as normal Python, where we don’t need special Prefect tasks like FilterTask or the case block.

video explanation

Audience

This is applicable for all users of Prefect 2.0 who may be familiar with writing Prefect 1.0 workflows that branch conditionally or filter results.

What is Staying the Same?

The way we define our tasks

What is different

  • We can use normal if blocks instead of the with case block
  • We can use the standard library filter expression to filter results instead of the Prefect FilterTask since in Prefect 2.0, we can materialize task results directly in the flow context
3 Likes