Hi, How to create a flow in prefect 2.0? I was usi...
# prefect-community
d
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
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
thanks @Nate
How can i create a flow with a dynamic flow name
n
I don't believe you can do this from the CLI, but with
run_deployment
you just pass a
flow_run_name
Copy code
run_deployment(name='hello-prefect/first-deployment-name', flow_run_name="custom-flowrun-name")