Koby Kilimnik
01/10/2022, 5:40 PMDanny Vilela
01/10/2022, 5:40 PMFlow
initializer has a name
keyword arg you can pass to it 🙂 i.e., with Flow(name="prod-etl")
.
Edit: ah nevermind! My bad.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()
Koby Kilimnik
01/10/2022, 5:43 PMKoby Kilimnik
01/10/2022, 5:43 PMKevin Kho
Koby Kilimnik
01/10/2022, 5:46 PMKoby Kilimnik
01/10/2022, 5:46 PMKoby Kilimnik
01/10/2022, 5:47 PMKoby Kilimnik
01/10/2022, 5:47 PMKevin Kho
from prefect import Flow, task, Parameter
from prefect.tasks.prefect import RenameFlowRun
import prefect
def rename_handler(obj, new_state, old_state):
if new_state.is_running():
new_name = f"myflow-{prefect.context.parameters["x"]}"
RenameFlowRun().run(flow_run_name=new_name)
return
@task
def first_task():
return 1
with Flow("test-flow", state_handlers=[rename_handler]) as flow:
param = Parameter("x", "test")
first_task()
Kevin Kho
Koby Kilimnik
01/10/2022, 5:59 PMKevin Kho