Fugo Takefusa
09/25/2025, 4:20 AMMarvin
09/25/2025, 4:20 AMMarvin
09/25/2025, 4:23 AM@task
? If all your work is done inside the @flow
body or in plain functions, there won’t be any task runs to show.
- Are tasks called inside a flow? Calling a task outside a @flow
won’t create a task run.
- Using subflows? A @flow
called from another @flow
is a subflow — it creates a nested flow run, not a task run. The Task Runs tab will be empty unless you also have `@task`s.
- Using get_run_logger()
? Call it inside a @flow
or @task
. Outside a run context it won’t attach to a task/flow.
- Using print
? Prints are not logged unless you set log_prints=True
on the flow/task.
Minimal example that will produce task runs (and task-level logs):
from prefect import flow, task, get_run_logger
@task(log_prints=True)
def transform(x: int) -> int:
logger = get_run_logger()
print("captured print from task")
<http://logger.info|logger.info>(f"transform got x={x}")
return x + 1
@task
def finalize(y: int) -> None:
get_run_logger().warning("finalize starting")
# do something
@flow(log_prints=True)
def my_flow():
get_run_logger().info("flow started")
a = transform(1) # creates a task run
finalize(a) # creates a task run
print("captured print from flow")
if __name__ == "__main__":
my_flow()
Common anti-patterns that lead to “No task runs”:
from prefect import flow, get_run_logger
def do_work(): # No @task here → no task run
logger = get_run_logger() # Not in a run context → not attached to a task
<http://logger.info|logger.info>("work") # May not show as a task log
@flow
def only_flow():
# All work here with plain functions/prints
do_work()
print("not captured unless log_prints=True")
Docs:
- Add logging in Prefect 3
- Source for tasks (for reference): prefect.tasks
If you can share a small snippet of how your flow and tasks are defined (especially where you call get_run_logger()
and whether you use `@task`/`@flow`), I can pinpoint exactly why your task runs aren’t showing.