Tejas Shah
03/03/2025, 2:23 PMMarvin
03/03/2025, 2:23 PMpython
from prefect import flow, task
@task
def inner_task(x):
return x * 2
@task
def outer_task(y):
result = inner_task(y)
return result
@flow
def my_flow(z):
result = outer_task(z)
print(result)
my_flow(10)
In this example, inner_task
is called within outer_task
, but both are defined as separate tasks. The flow my_flow
orchestrates the execution. This approach maintains task independence while allowing for nested-like behavior.
For more details on writing tasks in Prefect, you can refer to the Prefect 3.x documentation on writing tasks.