Team, Can someone share an example (Prefect 2.0) to have a flow with kwargs and pass parameter in the DeploymentSpec for the flow? So that I can pass many parameters dynamically. Thank you for your help.
from prefect.deployments import Deployment
from prefect.deployments import FlowScript
Deployment(
flow=FlowScript(path="/path/to/hello_flow.py", name="hello_world"),
name="Hello World-daily",
schedule=IntervalSchedule(interval=timedelta(days=1)),
parameters={"name": "Arthur"},
tags=["arthur","daily"],
)
🙌 1
🙏 1
x
Xavier Babu
07/21/2022, 10:34 PM
Thanks Andrew. Actually I may not know how many parameters I pass in that flow. It can be name or fname and lname or name and dob, etc. The flow should take the parameters I pass in DeploySpec as kwargs and use it inside my flow.
a
Andrew Huang
07/21/2022, 11:26 PM
Copy code
# filename: hello_flow.py
from prefect import flow
@flow
def hello_world(generic_kwargs=None):
generic_kwargs = generic_kwargs or {}
print("got {len(generic_kwargs)} kwargs!")
hello_world(generic_kwargs=dict(fname="fname", lname="lname"))
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.