Can I call a task from another task?

It’s not directly possible to call a task from another task, but you can call a task’s function from another task:

from prefect import flow, task, get_run_logger

def my_first_task(msg):
    logger = get_run_logger()"Hello, %s!", msg)

def my_second_task(msg):

def my_flow():

if __name__ == "__main__":

Note that this way, you are only calling the task’s function without actually generating a task run. It has a negative effect on observability - Prefect won’t track task execution in your Prefect backend if you call a task this way. :warning:

in the above example, you only run my_second_task, which calls my_first_task 's function, but it doesn’t trigger its task run – this could get confusing in the UI, so make sure to use that intentionally.