Hi, How to create a flow in prefect 2.0? I was using create_flow_run from prefect.tasks.prefect.flow_run in prefect 1.0 ?
n
Nate
04/16/2023, 1:21 AM
hi @darshan darshan
in prefect 2, you can create a flow like this:
Copy code
from prefect import flow, task
@task
def say(message: str):
print(message) # note this logged since tasks inherit log_prints=True
@flow(name="hello-prefect", log_prints=True)
def hello_world_flow(message: str):
say(message)
# and run it
if __name__ == "__main__":
hello_world_flow('hi from earth!')
and then if you want to deploy this and then create a flow run of it, you can:
• use the cli
Copy code
prefect deployment run 'hello-prefect/first-deployment-name'
• use the python api
Copy code
from prefect.deployments import run_deployment
run_deployment(name='hello-prefect/first-deployment-name')
d
darshan darshan
04/16/2023, 7:10 AM
thanks @Nate
darshan darshan
04/16/2023, 7:11 AM
How can i create a flow with a dynamic flow name
n
Nate
04/16/2023, 4:21 PM
I don't believe you can do this from the CLI, but with
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.