@Marvin what does prefect when a task or a flow is called with ".fn()"?
m
Marvin
08/02/2024, 1:46 PM
When a task or a flow is called with
.fn()
in Prefect, it accesses the original function directly, allowing you to test the task or flow in isolation without invoking the full Prefect runtime environment. This is particularly useful for unit testing.
Here’s an example of how to use
.fn()
with a task:
Copy code
python
from prefect import flow, task
@task
def my_favorite_task():
return 42
@flow
def my_favorite_flow():
val = my_favorite_task()
return val
def test_my_favorite_task():
assert my_favorite_task.fn() == 42
Bring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.