@Marvin If I am deploying a workflow with the .serve method, can I pass parameters to that workflow? If so please give an example.
m
Marvin
01/08/2025, 5:20 PM
Yes, you can pass parameters to a workflow when using the
.serve
method in Prefect 3.x. The
serve
method is a long-running process that allows you to execute remotely triggered or scheduled runs, and you can serve multiple flows using this utility.
Here's an example of how you might define and serve a flow with parameters:
Copy code
python
from prefect import flow, serve
@flow
def my_flow(param1: int, param2: str):
print(f"Running with param1: {param1} and param2: {param2}")
if __name__ == "__main__":
# Serve the flow, which allows it to accept parameters when triggered
serve(my_flow)
When you trigger this flow through the Prefect UI or API, you can specify the parameters
Bring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.