<@ULVA73B9P> how do i run a flow function without ...
# ask-marvin
b
@Marvin how do i run a flow function without running it as a flow? Ex i just want to invoke the code, but not the flow extra functionality
m
To run a flow function directly as normal Python code without invoking the extra functionality of a flow, you just call the flow decorated function like any other Python function. Here's an example of how to define and call a flow function without triggering the flow execution:
Copy code
python
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