https://prefect.io logo
Title
q

quassy

05/23/2023, 5:26 PM
Is there any way to actually rename a flow run in Prefect 2 with
@flow(flow_run_name="foobar")
? Even the examples from the docs copied verbatim do not work (see replies).
from prefect import flow
@flow(flow_run_name="{name}-on-{date:%A}")
def my_flow(name: str, date: datetime.datetime):
    pass
# creates a flow run called 'marvin-on-Thursday'
my_flow(name="marvin", date=datetime.datetime.utcnow())

19:24:18.752 | INFO    | prefect.engine - Created flow run 'petite-coucal' for flow 'my-flow'
19:24:20.586 | INFO    | Flow run 'petite-coucal' - Finished in state Completed()
Also passing a function is ignored:
from prefect import flow
def generate_flow_run_name():
    date = datetime.datetime.utcnow()
    return f"{date:%A}-is-a-nice-day"
@flow(flow_run_name=generate_flow_run_name)
def my_flow(name: str):
    pass
# creates a flow run called 'Thursday-is-a-nice-day'
my_flow(name="marvin")

19:24:40.895 | INFO    | prefect.engine - Created flow run 'furry-quail' for flow 'my-flow'
19:24:42.444 | INFO    | Flow run 'furry-quail' - Finished in state Completed()
Also a basic custom function get's ignored:
def get_flow_run_name() -> str:
    flow_name = flow_run.flow_name
    flow_time = datetime.now().strftime("%Y%m%dZ%H%M%S")
    return f"{flow_name}-{flow_time}"
w

Will Raphaelson

05/23/2023, 11:01 PM
Hey @quassy - this seems to be a bug. I’m finding its totally ignored as well. I’ll file at github issue
👍 1
so interestingly it looks as if the flow run is actually named correctly, but were still logging the incorrect one. I wrote this up here if you want to follow along. Thanks for raising. https://github.com/PrefectHQ/prefect/issues/9706
🙌 1
q

quassy

05/24/2023, 8:47 AM
Ok so I guess it's only named in the Prefect UI but also the Kubernetes pod keeps the name of the old job, which makes the renaming even less useful because you lose the connection by name between the Prefect job and the Kubernetes pod.