bral
11/16/2021, 8:15 PMclient.create_flow_run(
flow_id="d7bfb996-b8fe-4055-8d43-2c9f82a1e3c7",
flow_run_name="docs example hello-world"
)
But when run triggered by prefect the names are random. Or you can set manualy from UI flow_run_name.
My tipical prefect script looks like :
@task
def task1():
pass
@task
def task1():
pass
with Flow() as flow:
task1()
task2()
...
client.register(flow, project_name='project')
Is there way set run_flow_name by default in code?
For example:
name = f"name_{datetime.datetime.utc()}"
Kevin Kho
from prefect import Flow, task
from prefect.tasks.prefect import RenameFlowRun
def rename_handler(obj, new_state, old_state):
if new_state.is_running():
RenameFlowRun().run(flow_run_name="new_name")
return
@task
def first_task():
return 1
with Flow("test-flow", state_handlers=[rename_handler]) as flow:
first_task()
bral
11/16/2021, 8:31 PM