Is there a way to rename a flow already registered...
# prefect-community
s
Is there a way to rename a flow already registered with Orion/Cloud? I want to change its name and not lose run history
1
sad keanu 1
I had hoped to use this API endpoint, but that seems to be only for updating tags 🤔 Thoughts?
🙁 1
1
Github issue created - https://github.com/PrefectHQ/prefect/issues/8154 This seems to not be possible at the moment.
a
@Stéphan Taljaard did you succeed to add tags to your flow on runtime? I always have “flow not found”, however I take id with:
prefect.context.get_run_context().flow_run.dict()["id"]
s
Hi Aleksandr! I didn't actually want to add tags to my flow; I wanted to rename existing flows. I'll quickly check if I can add tags to a flow run, at runtime
@Aleksandr Liadov This did the trick for me:
Copy code
@task
async def set_flow_run_tags(tags: list[str]):
    task_run_context = prefect.context.get_run_context()
    flow_run_id = task_run_context.task_run.flow_run_id

    async with prefect.client.orion.get_client() as client:
        response = await client.update_flow_run(flow_run_id=flow_run_id, tags=tags)

@flow
def main():
    set_flow_run_tags(["tags", "at", "runtime"])
You trust it should also work similarly if you want to do it inside the flow itself (i.e. not as a task)
👍 1
🙌 1
a
@Stéphan Taljaard thanks a lot! At least I can add a tag now. P.S I can rename flow now, your trick is working 🦄
highfive 1
🙌 1
s
Note that renames the flow run, not really the flow itself. But I'm happy this is working 🎉
🙌 1