Is there any way to actually rename a flow run in ...
# prefect-getting-started
q
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).
Copy code
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:
Copy code
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:
Copy code
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
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
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.