Blake
05/13/2024, 12:11 AMMarvin
05/13/2024, 12:11 AMpython
from prefect import flow
@flow(log_prints=True) # send `print` statements as INFO logs
def my_workflow():
print("I can call any python code here, including prefect tasks or flows")
if __name__ == "__main__":
my_workflow() # call it like a normal python function
In the code above, the my_workflow()
function decorated with @flow
can be called normally. Ensure that you call the function within the if __name__ == "__main__":
block so that it does not get executed when the script is imported elsewhere.
Source: Prefect Code Examples - Basic Flow