https://prefect.io logo
Title
a

Andor Tóth

02/28/2020, 2:20 PM
I was wondering, after thoroughly looking in the documentation, that how could I execute a single task on it’s own from a flow?
d

Dylan

02/28/2020, 2:57 PM
Hey @Andor Tóth! For testing purposes or in an
ipython
session, you can run a task by calling the task’s run method directly:
from prefect import task

@task
def my_task():
    print("Hello, World!")

output = my_task.run()
Let me know if that doesn’t answer your question
n

Nicholas Perrott

03/03/2020, 3:52 AM
This technique would be good to add to the documentation. Perhaps a small section with recommendations on how best to unit test tasks/flows, could cover this technique.
d

Dylan

03/03/2020, 6:52 PM
@Nicholas Perrott great suggestion! There’s a small note here: https://docs.prefect.io/core/getting_started/why-not-airflow.html#local-testing but I think that’s a bit hard to find. I’ll open an issue 👍