Hi, I tried to search but don’t seems find related...
# ask-community
t
Hi, I tried to search but don’t seems find related answer. I want to change the auto-generated container like names “happy-jelly” stuff. But I don’t want to overcomplicate things like to
create_flow_run
in code. What’s the simpliest thing to change by giving the flow run a customized run-id? Assume I only need to trigger the flow run using schedules or UI.
k
Hey @Tony Yun, the simplest way would be to use the
RenameFlowRun
task inside your flow code. Docs
t
does it require to add a task for renaming a flow run id?..
k
That’s more automated, but through the UI you can hover over the flow run name and a pencil will appear and you can click it.
t
the UI change is for one-time only looks like.
so there is no parameter/configuration to set the flow run id during initialization?
k
create_flow_run
takes in a
run_name
argument if you are using the
Client
t
using Client is also one time only triggers I thought?
for schedules, nobody ever think to rename the run id to make it making some sense?.. I thought this is a very straightforward idea. but all of the scheduled jobs are being named randomly which I tell no clue by looking at UI.
k
Sorry I am confused. If you want it recurring and always changing for scheduled runs, then
RenameFlowRun
in the flow would be the easiest approach. It can’t be set as the flow is created, unless a one time thing with
create_flow_run
t
thanks! btw, the example in the API doc is very outdated. After correcting the errors, I can’t seem do it right still:
Copy code
RenameFlowRun("hello-flow-1", flow_run_name='test-1')

with Flow(
    "hello-flow", 
    schedule
) as flow:
    # download_report()
    load_report(upstream_tasks=[download_report])
also I don’t know what’s the difference between flow-run-id and flow-run-name
k
The id is a uuid and the name is the string.
RenameFlowRun
has to be inside the
Flow
You don’t need to supply the id. Just do
RenameFlowRun()(flow_run_name="new_name")
inside the Flow.
t
hmm, it seems it’s not a good practice. I’ll give it up using it this way then. Thank you for the help!
Copy code
/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/contextlib.py:120: UserWarning: Tasks were created but not added to the flow: {<Task: RenameFlowRun>}. This can occur when `Task` classes, including `Parameters`, are instantiated inside a `with flow:` block but not added to the flow either explicitly or as the input to another task. For more information, see <https://docs.prefect.io/core/advanced_tutorials/task-guide.html#adding-tasks-to-flows>.
k
You need it under the flow block:
Copy code
with Flow(
    "hello-flow", 
    schedule
) as flow:
    RenameFlowRun()(flow_run_name='test-1')
    load_report(upstream_tasks=[download_report])
👍 1